Home > Blockchain >  How to plot chart by ggplot2 with fixed scale?
How to plot chart by ggplot2 with fixed scale?

Time:01-31

I need to draw different kind of pics using ggplot2 in R and it have to be in proper scale when I print it. It means that I have to define exact image and chart size, the same scale of x/y-axes.

Could you please advice me what kind of options I should to use?

ggplot(Surface, aes(x, y, z = z))  
  geom_contour_filled(binwidth = 10, alpha = 0.6)  
  geom_textcontour(binwidth = 20, size = 2.5)

CodePudding user response:

If you mean geom_text_contour from metR package then we could do:

This example is taken from here enter image description here

CodePudding user response:

Maybe you want to use coord_fixed with ratio argument:

aspect ratio, expressed as y / x

Here is your code:

library(ggplot2)
ggplot(Surface, aes(x, y, z = z))  
  geom_contour_filled(binwidth = 10, alpha = 0.6)  
  geom_textcontour(binwidth = 20, size = 2.5)  
  coord_fixed(ratio = 2/1)
  • Related