# Why does the scale of my graph change when I save my plot as an svg?

I have created a graph in R Studio, and the graph looks good in the "Plots" window (i.e., my axis intervals range from -800 to 100), however, when I save the plot as an image, I lose the "100" interval. Does anyone know why this is happening or a work around for this?

Thanks

enter image description here

I have tried customizing the axis from the default using the code:

axis(side = 2, at = c(100, 0, -100, -200, -300, -400, -500, -600, -700, -800), family = "A", cex.axis = 1.5)

Once again, the plot looks good in the "Plots" window, but then when I save the plot as an image, the 100 interval is cut off.

It is probably a matter of fiddling with .svg co-ordinates but I think we need a see your code and some sample data.

How to do a minimal reproducible example reprex.

Thank you, I have included my code, as well as the data that I am working on (phosphate.dat - provided below).

# create a plot for phosphate

phosphate.dat
phosphateplot <- barplot(phosphate.dat\$mean~phosphate.dat\$Site, ylim = c(-800, 200), xlab = "Site", ylab = "Phosphate Reduction (%)", family = "A", cex.lab = 1.5, cex.axis = 1.5, cex.sub = 1.5, cex = 1.5, yaxt = 'n')

phosphateplot <- barplot(phosphate.dat\$mean~phosphate.dat\$Site, ylim = c(-800, 200), xlab = "Site", ylab = "Phosphate Reduction (%)", family = "A", cex.lab = 1.5, cex.axis = 1.5, cex.sub = 1.5, cex = 1.5, yaxt = 'n')

axis(side = 2, at = c(100, 0, -100, -200, -300, -400, -500, -600, -700, -800), family = "A", cex.axis = 1.5)

arrows(x0 = phosphateplot,
y0 = phosphate.dat\$mean + phosphate.dat\$se,
y1 = phosphate.dat\$mean - phosphate.dat\$se,
angle = 90,
code = 3,
length = 0.1)

###########################################################################
phosphate.dat
Site mean sd sample_size se
1 BC1 -630.30 0.00 1 0.00000
2 BC2 41.79 66.99 5 29.95884
3 BC3 -634.36 0.00 1 0.00000

I am not sure why everything looks good in the plots panel, but not when I export

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.