I love Julia, but I still do not figure out how to make pretty plots. The figure size is in pixels rather than inches, which complicates things when you want to set font sizes (in points). LaTeXStrings does not work in Windows. I’ve been trying to fix it without success.
I want to create a customized plot (see code below), but I get many warnings latex: failed to create a dvi file
.
The problem boils down to:
- I cannot insert latex tex
- Cannot control the figure and font sizes in inches
- The figure is cropped when I save it
- The font does nothing when I try to use Euclid or CMU
I’ve been trying to fix all of this, but without success. I will really appreciate any help to understand how this works and how I could fix it.
Thanks in advance.
using Plots, LaTeXStrings
dpi = 300
w = 3.5 * dpi
h = 2 * dpi
font_size = Int(round(10 / 0.75 / 72 * 100))
font_name = "Times"
p = plot(sin, 0, 2π,
title=L"y = x_t, Title",
titlefont=font(font_size, "sans"),
xlabel="X label",
ylabel="Units",
xguidefont=font(font_size, font_name), ## x-label
yguidefont=font(font_size, font_name), ## y-label
xtickfont=font(font_size, font_name),
ytickfont=font(font_size, font_name),
tickfont=font(font_size, font_name), # x,y-ticks font
label="Sin function",
legendfont=font(font_size, font_name),
xlims=(0, 2π),
ylims=(-1, 1),
)
plot!(size=(w, h), dpi=dpi)
savefig(p,"file.png")