Display and save aspect ratio chart in ggplot2

I want to create a horizontal histogram and adjust the aspect ratio of the chart using ggplot2 .

For example, let's say my diagram is dia <- ggplot(diamonds, aes(x=color)) + geom_bar() .

I can flip it horizontally using dia + coord_flip() .

I can also adjust aspect ratio for example. dia + coord_fixed(ratio=.001) .

But when I combine them dia + coord_flip()+ coord_fixed(ratio=.001) , the diagram is no longer horizontal.

Is there a way to achieve what I want to use ggplot2 ?

+1
source share
1 answer

See this answer on the ggplot2 mailing list :

You can use only one coordinate function _ * () on a given ggplot, since it changes the coordinate system after everything else is done. to change the aspect ratio, you can use the corresponding argument in the thematic system:

  + coord_flip() + theme(aspect.ratio = 1) 
+4
source

Source: https://habr.com/ru/post/1263975/


All Articles