Hi @AAL . Using Plots and the pgfplotsx() backend, the trick is done by inserting fg_legend = :transparent
into the plot function’s properties, like this
using Plots
using LaTeXStrings # edditing with Latex
pgfplotsx() # pgfplotsx() backend
#gr()
f(x) = -2 + 10sin(x)
g(x) = -2 + 3x
q(x) = -10+x^2
plot(
[f, g, q],
-5:0.01:5,
label=[L"f(x)" L"g(x)" L"q(x)"],
title = L"My \; Figure",
xlabel = L"Peanuts",
ylabel = L"\alpha (m/s)",
fg_legend = :transparent # the line edges of the legend box disappear
)
The plot will look like this:
If you do it directly using PGFPlotsX, the trick is to insert legend_style= "{draw=none}"
into the Axis
properties, like this (sorry for raw LaTeX code at the top of the code, but it does not interfere in any way with what you want; it is intended to change the default layout of the plots in PGFPlotsX):
using PGFPlotsX
using LaTeXStrings
push!(PGFPlotsX.CUSTOM_PREAMBLE,
raw"\pgfplotsset{tick label style = {font = {\fontsize{12 pt}{12 pt}\selectfont}},
label style = {font = {\fontsize{12 pt}{12 pt}\selectfont}},
legend style = {font = {\fontsize{12 pt}{12 pt}\selectfont}},
}"
)
@pgf a = Axis({
no_marks,
legend_pos = "north west",
legend_style= "{draw=none}", # To avoid the boxed legend style
height = "10cm",
width = "20cm",
grid = "major",
xlabel = L"\textbf{Date}",
ylabel = L" \color{blue} CPI \ (\% change) \ , \ \color{red} FFR \ (\%)",
x_tick_label_style="{/pgf/number format/1000 sep=}", # To avoid commas in the thousands
ytick_distance ="5", # set the distance betwen each tick
title = L"\textbf{Consumer Price Index and Federal Funds Rate (US: 1960:M1---2020:M6)}",
xmax = 2022,
xmin = 1958,
ymax = 20,
ymin = -5,
},
Plot(Table([Years, CPI]),
{
color = "blue",
style = "{thick}"
}),
LegendEntry(L"CPI"),
Plot(Table([Years, FFR]),
{
color = "red",
style = "{thick}"
}),
LegendEntry(L"FFR"),
)
#pgfsave("PGFPlotsX_TimeSeries.pdf", a) #save plot as a pdf
The plot would look like this (sorry, you can not replicate the figure as you don’t have the data):