ggplot2 - r stat_contour incorrect fill with polygon -
When I use This is the cutting code: It was not fit in a comment , So posting as an answer: stat_contour does not handle polygones that are not very well closed In addition, there is a precise issue that can be harvested while manually setting bins, which can lead to actual contour calculation (this happens when the contour bins are similar to the plot data, but due to precise issues, Are not recognized as such) The first issue that you can extend your grid all the way around in every direction, and then you can define each value in the matrix, which is less than the lowest, which gives you some arbitrary Let's look at the low value. It will compel the computation of all the polygons which will otherwise open on the edges of the conspiracy. Then you can set the border with The second issue that I do not know is that you can not be affected by this problem, a good way to solve the GGPlot code without modifying it. stat_contour with polygon, some areas should not be filled because there Does anyone have any data, I figured them out in Figure to know how to avoid? In addition, the spindle and the plot are in the middle of the field, how can it be removed ?!
plot_contour & lt; - function (da, native) {H2d & lt; -hist2d (da $ germ_div, da [[original]], nbins = 40, show = f) calculation of h2d $ & lt; -h2d $ number + 1 counts & lt; -log (h2d $ counts, base = 10) rownames (count) & lt; -h2d $ x colnames (count) & lt; -h2d $ y counts & lt; -melt (count) name (count) & lt; -c ('x', 'y', 'z') ggplot (count, aes (x, y)) + stat_contour (extension = c (0,0), aes (z = z, fill = .. level. .., geom = 'polygon') + stat_contour (data is calculated as $ x <= 75,), aes (z = z, fill = .. level ..), bins = 50, geom = 'polygon') + scale_fill_gradientn (extension = C (0,0), color = rainbow (1000), border = c (log (2, base = 10), 4), na.value = 'white', guide = F ) + geom_contour (aes (z = z, color = .. level ..), size = 1.5) + Scale_color_gradientn (color = rainbow (30), border = c (log (2, base = 10), 4), na .value = 'white', guide = F) + theme_bw () + scale_x_continuous (extension = c (0,0), range = c (0, 50)) + scale_a continuous (extension = c (0,0), border = C (4 0,100) + Laboratories (X = Faucet, Y = Zero, Title = Faucet) + them E (axis.text.x = element_text (family = 'times', color = "black", size = 20, angle = faucet, hjust = NULL, vjust = NULL, face = "plain"), Axis Text.y = Element_text (family = 'times', color = "black", size = 20, angle = null, hjust = null, vjust = NULL , Faces = "plain"))} da & lt; -read.table ('test.txt', header = t) I & lt; - 'test' plot_contour (da, i)
coord_cartesian (xlim = c (...)) to flush your axis from the graph.
Comments
Post a Comment