Hi Luis, my suggestion follows.
```
library(geepack)
library(ggplot2)
library(sjPlot)
library(ggeffects)
# #Copy dataset before following the code
# dat <- read.delim("clipboard", dec=","); attach(dat)
# I orefer to read from file.
dat <- readr::read_csv("Data - Hoja 1.csv")
dat
dat$Id <- as.integer(factor(dat$Esp))
str(dat)
m5 <- geeglm(
formula = tim ~ Pa*Pt,
family = Gamma(link = log),
data = dat,
id = Id,
corstr = "exchangeable"
)
anova(m5,test="chisq")
p <- plot_model(m5, type = "pred", terms = c("Pt[n=100]", "Pa"),
digits=1, line.size=0.5, show.data=T,
#colors=c("green","#00a0c9","red")
colors = viridisLite::magma(begin = 0.2, end = 0.8, n = 3)
# Color blind friendly.
)
p <- p + scale_x_continuous(breaks=c(1, 2, 3))
p <- p + ylab("Descriptive ylab (tim)")
p <- p + xlab("Descriptive xlab (Pt)")
p <- p + theme_bw() # My preference.
p
ggsave(filename = "my_plot.tiff", device = "tiff", dpi = 300,
width = 3.25, height = 3.25, units = "in", compression = "lzw")
ggsave(filename = "my_plot.png", device = "png", dpi = 300,
width = 3.25, height = 3.25, units = "in")
```
I believe the pixelation issue you've mentioned can be addressed by
increasing the resolution(dpi=300). Although a vector graphic, as suggested
by Torsten, is another alternative.
You appear to be treating your data as continuous (lm) but are trying to
assign discrete x-axis tick labels. I think I have had more success by
treating your data as continuous. (But, your data do look
rather categorical.)
Note that `ggsave()` includes the ellipsis (`...`) which allow you to pass
parameters to functions called by `ggsave()`.
Hope that helps!
Brian
On Thu, Jun 3, 2021 at 1:23 AM Torsten Hauffe
wrote:
> Hi Luis,
>
> You can avoid the pixelation by exporting your plot as vector graphics
> (e.g. functions pdf() or svg()) instead of pixel formats (i.e. png(),
> tiff() etc). There is also ggsave("MyPlot.pdf") but I don't know about
> ggplot very well.
>
> pdf("MyPlot.pdf")
> p= plot_model(m5, type = "pred", terms = c("Pt[n=100]", "Pa"),
> digits=1,line.size=0.5,show.data=T,colors=c("green","#00a0c9","red"))
> dev.off()
>
> On Thu, Jun 3, 2021 at 10:10 AM Luis Fernando García >
> wrote:
>
> > Dear all,
> >
> > I am wanting to improve a plot made with the package sjPlot.
> >
> > When plotting this model
> >
> >
> > Plot produced looks like this
> >
> >
> https://docs.google.com/presentation/d/1Pqm6BcJXdSQ6U1zmv5FV7gBcn1afHHv7rlQHe6j59_c/edit?usp=sharing
> > ,
> > especially red and green lines.
> >
> > I just have two concerns with this, the first one is that lines seem a
> bit
> > pixelated, and I would like to improve it, I have tried some approaches
> but
> > it has not been possible.
> >
> > Dataset in this link:
> >
> >
> https://docs.google.com/spreadsheets/d/1nXerN91Iehe9OM1VGDMS3jnbvvF1tWcuS9bGtlrj_Ss/edit?usp=sharing
> >
> > library(geepack)
> > library(ggplot2)
> > library(sjPlot)
> > library(ggeffects)
> > #Copy dataset before following the code
> > dat <- read.delim("clipboard", dec=","); attach(dat)
> >
> > dat$Id <- as.integer(factor(dat$Esp))
> > str(dat)
> > m5 <- geeglm(
> > formula = tim ~ Pa*Pt,
> > family = Gamma(link = log),
> > data = dat,
> > id = Id,
> > corstr = "exchangeable"
> > )
> >
> > anova(m5,test="chisq")
> >
> > p= plot_model(m5, type = "pred", terms = c("Pt[n=100]", "Pa"),
> > digits=1,line.size=0.5,show.data=T,colors=c("green","#00a0c9","red"))
> >
> > p
> >
> > The second one, is I would like to remove the decimal values (i.e. in
> the x
> > axis), however I´m not very sure if it is possible to do this in sjPlot
> or
> > if you know a similar alternative in ggplot2. I tried this approach but
> it
> > did not work.
> >
> > p=p+ scale_x_discrete(limits=c(1,2,3))
> > p
> >
> > When making this plot, there is a space before 1 and after 3 I would like
> > to erase.
> >
> > Best
> >
> > [[alternative HTML version deleted]]
> >
> > ___
> > R-sig-ecology mailing list
> > R-sig-ecology@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
> >
>
> [[alternative HTML version deleted]]
>
> ___
> R-sig-ecology mailing list
> R-sig-ecology@r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-ecology
>
[[alternative HTML version deleted]]
___
R-sig-ecology mailing list
R-sig-ecology@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-ecology