[R] Help needed with getting a decent image of ggplot2 graph

bharat rawlley bh@r@t_m_@|| @end|ng |rom y@hoo@co@|n
Wed Aug 25 00:21:08 CEST 2021


Hello, I made the following graph in R with the following code.
ggplot(aes(x=factor(year), y=percentage, color = Gender, fill=Gender), data = graph_text)+  geom_bar(position = 'dodge', stat='identity')+  theme_classic()+  scale_y_continuous(limits=c(0, 1.4*ymax))+  labs(x= 'Year', y = 'Percentage', title = 'Men and Women')



However, on using the following code - tiff("test.tiff", units = "px", width = 440, height = 250, res = 300)ggplot(aes(x=factor(year), y=percentage, color = Gender, fill=Gender), data = graph_text)+  geom_bar(position = 'dodge', stat='identity')+  theme_classic()+  scale_y_continuous(limits=c(0, 1.4*ymax))+  labs(x= 'Year', y = 'Percentage', title = 'Men and Women')dev.off()


I get the following image - 



I need to keep the DPI = 300 and Width = 440 fixed. I can only manipulate height. Any help would be appreciated
Thank you
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1629843563534blob.jpg
Type: image/png
Size: 34899 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20210824/a35847e1/attachment.png>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 1629843619873blob.jpg
Type: image/png
Size: 18367 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20210824/a35847e1/attachment-0001.png>


More information about the R-help mailing list