user12257
user12257

Reputation: 11

How to improve line quality and edit axis in sjPlot

I am wanting to improve a plot made with the package sjPlot.

When plotting the code below, plot produced looks like this enter image description here

I just have two concerns with this, the first one is that lines seem a bit pixelated (mainly the lines red and green), 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

    # Please copy the dataset from the link before following the code
library(ggplot2)
library(sjPlot)
library(ggeffects)
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. 1.5 and 2.5 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+ scale_x_discrete(limits=c(1,2,3))

When making this plot, there is a space before 1 and after 3 I would like to erase.

enter image description here

Many thanks for any help you can provide!

Upvotes: -1

Views: 183

Answers (1)

KaptajnKasper
KaptajnKasper

Reputation: 170

The pictures you have included look like screenshots, if you are to use the plot in a report for example i always export my figure as either png for pdf format. If you use the png format with too low resolution your plots can become pixelated, but with the right resolution for the application it works fine. Personally i most often use the pdf format to produce vector graphics, that never become pixelated.

If you use RStudio there is functionality to save a plot via the GUI, but ggplot2 also provides the function ggsave you can use to save a plot.

Upvotes: 0

Related Questions