Jim Lemon
2021-Aug-24 22:54 UTC
[R] Help needed with getting a decent image of ggplot2 graph
Ah, an _upper_ limit. Why not let tiff() work out the resolution (res=NA - the default) and see if that passes muster. Jim On Wed, Aug 25, 2021 at 8:42 AM bharat rawlley <bharat_m_all at yahoo.co.in> wrote:> > I am able to change but the place where I have to submit a similar graph has kept a fixed upper limit of 440 pixels for the width and an upper limit of 300 for the dpi. > > On Tuesday, 24 August, 2021, 06:36:16 pm GMT-4, Jim Lemon <drjimlemon at gmail.com> wrote: > > > Hi bharat, > I think there is a conflict between your image size and resolution. > You need a lot larger height and width in pixels to get 300 dpi > resolution for the whole plot. > > tiff("test.tiff", units = "px", width = 2200, height = 1250, res = 300) > > would probably do it for you. How come you can't change the width and > height in pixels? > > Jim > > On Wed, Aug 25, 2021 at 8:22 AM bharat rawlley via R-help > <r-help at r-project.org> wrote: > > > > 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 > > > ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. >
bharat rawlley
2021-Aug-25 00:00 UTC
[R] Help needed with getting a decent image of ggplot2 graph
I tried doing that.? So the real title of my graph is much longer than men and women and isn't not being incorporated in that width.? I think I'll have to settle for a smaller title? Sent from Yahoo Mail on Android On Tue, 24 Aug 2021 at 6:54 PM, Jim Lemon<drjimlemon at gmail.com> wrote: Ah, an _upper_ limit. Why not let tiff() work out the resolution (res=NA - the default) and see if that passes muster. Jim On Wed, Aug 25, 2021 at 8:42 AM bharat rawlley <bharat_m_all at yahoo.co.in> wrote:> > I am able to change but the place where I have to submit a similar graph has kept a fixed upper limit of 440 pixels for the width and an upper limit of 300 for the dpi. > > On Tuesday, 24 August, 2021, 06:36:16 pm GMT-4, Jim Lemon <drjimlemon at gmail.com> wrote: > > > Hi bharat, > I think there is a conflict between your image size and resolution. > You need a lot larger height and width in pixels to get 300 dpi > resolution for the whole plot. > > tiff("test.tiff", units = "px", width = 2200, height = 1250, res = 300) > > would probably do it for you. How come you can't change the width and > height in pixels? > > Jim > > On Wed, Aug 25, 2021 at 8:22 AM bharat rawlley via R-help > <r-help at r-project.org> wrote: > > > > 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 > > >? ______________________________________________ > > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. >[[alternative HTML version deleted]]