Drawing labels on flat section of contour lines in ggplot2

前端 未结 2 1197
星月不相逢
星月不相逢 2021-02-05 16:09

In a previous question, I reproduced a contour plot generated with the fields package, in ggplot2 instead (full example below). The only trouble is, I would like to replicate t

2条回答
  •  青春惊慌失措
    2021-02-05 17:08

    You need to implement the algorithm from here:

    https://github.com/wch/r-source/blob/c3ba5b0be36d3a1290e18fe189142c88f1e43236/src/library/graphics/src/plot3d.c#L1668

    the function doesn't return any information about the position of the contour labels, it does the actual drawing on the graphics device, so you can't hook it into ggplot. It also knows not to draw the contour line under the label.

    Until this is implemented in ggplot, stick with base graphics.

提交回复
热议问题