-
-
Notifications
You must be signed in to change notification settings - Fork 358
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Issues with saving plot as pdf #3004
Comments
It's possible that this is caused by an issue the underlying GR backend's pdf driver: https://gr-framework.org/encoding.html |
I just wanted to point out that I am having the same issue with the Times Roman font. Minimum working example below: using Plots
gr()
x = -10:10
p = plot(x,x, ytickfont = Plots.font("times"))
savefig(p,"asPNG.png")
savefig(p,"asPDF.pdf") The error does not occur with certain other fonts, e.g. Computer Modern. |
I find this issue still holds for the "-" sign. Is there a way to setup the encoding or how the pdf render works for Plots ? This is a code I run on MacOS, but it holds years now. using Plots
# _ Fonts
ftb = ["times", "Helvetica", "courier", "Computer Modern", "bookman", "newcenturyschlbk", "avantgarde", "Palatino", "serif-roman", "sans-serif"]
# _ different backends, tested only gr() in Plots
backend_x = "plots_gr"
gr()
x = [randn(50) for i in 1:3]
xt = LinRange(-2,2,50)
plots_array = []
for (i, fi) in enumerate(ftb)
# label tests - sign in other texts as labels or legend
p1 = scatter(xt, x, label=["x1 (-1,1)" "x2 +4" "x3 -98"], title="font $fi", framestyle=:box, fontfamily=fi, size=(400,400), ylabel="-3 -text", xlabel="-3 -text")
push!(plots_array, p1)
display(p1)
savefig(p1, "plots/problem/plot_b_$(backend_x)_f_$fi.pdf")
end
[display(p) for p in plots_array] |
It does not seem to be resolved yet. I am using |
I'm getting the same error. I'm also on Mac and trying to save a pdf of the plot with Palatino as the fontface. It would be great if anyone has a solution. |
Same error here, font is Helvetica. |
When on macOS, |
Palatino still not saved properly, is there a way to use different fonts with Plots and have correct symbols? |
Details
I was trying to save plots generated using gr() backend in pdf format and this messes up the negative values along x & y-axes. This doesn’t seem to happen when the figure is saved as png though. I isolated this issue to the plot() argument,
fontfamily = font(48, "helvetica")
. I am attaching the MWE I used belowFigure saved as png
Figure saved as pdf
test.pdf
Backends
This bug occurs on ( insert
x
below )Versions
Plots.jl version: Plots v1.6.6
Backend version (
]st -m
): GR v0.52.0Output of
versioninfo()
: Julia Version 1.5.2Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.7.0)
CPU: Intel(R) Core(TM) i5-5287U CPU @ 2.90GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, broadwell)
Environment:
JULIA_NUM_THREADS = 2
The text was updated successfully, but these errors were encountered: