Skip to content
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

Changing tikz options withPGFPlotsX.Options deletes all default options, instead of just adding the new option #319

Open
andresdrenik opened this issue Jun 1, 2023 · 5 comments

Comments

@andresdrenik
Copy link

Hi,

First of all, huge thank you for this amazing package!

Here is a simple example that illustrates my issue. I'm plotting two lines in the following way:

      pgfplotsx()
      default(legendfonthalign = :left,
              xtickfontsize = 18,
              ytickfontsize = 18,
              legendfontsize = 18,
              xlabelfontsize = 18,
              ylabelfontsize = 18,
              markersize = 10,
              linewidth = 3,
              size = (600, 400))

      y = rand(100,2)
      plot(y, legend=:topright)

Sometimes my legendfontsize needs to be large, but then the labels start overlaping with each other. In Tikz one can fix this by increasing the gap between the labels by adding {row sep={2.5pt}} inside legend style set of options. This can be easily done in my previous example with

plot(y, legend=:topright, legend_style = PGFPlotsX.Options("row sep" =>"2.5pt"),extra_kwargs = :subplot)

Now, when I save my tikz figure I do see the new option. The problem is that

legend_style = PGFPlotsX.Options("row sep" =>"2.5pt"),extra_kwargs = :subplot

deletes all my legend options (the default ones by Tikz and the ones I specify in default()). It'd be great if there was a way to just add an option, while keeping the default ones.

Thanks again!

@KristofferC
Copy link
Owner

It is unclear if this is an issue in Plots using this as a backend or in this package. Do you have a repro that only uses PGFPlotsX?

@andresdrenik
Copy link
Author

I'm fairly new to PGFPlotsX, but please let me know what you'd like to see and I can come up with an example that only uses PGFPlotsX.

@KristofferC
Copy link
Owner

Something that shows a bug in PGFPlotsX.jl :)

@andresdrenik
Copy link
Author

I'm not sure how to do that. By definition, when you create a plot with PGFPlotsX, you need to specify all the options yourself. In that case, when creating the plot, I'd manually write all the default options behind plot(y, legend=:topright) and I'd also add "row sep" =>"2.5pt" to legend_style. This method should definitely work and should not reveal any bug.

Alternatively, is there a way to create a plot with the pgfplotsx() backend (e.g., my simple plot(y, legend=:topright)) and then modify an option with push/merge/append (as https://kristofferc.github.io/PGFPlotsX.jl/stable/man/options/)? Or somehow "convert" the p1 = plot(...) object into pgfplotsx so that options can be later modified?

@BeastyBlacksmith
Copy link
Contributor

You can via Plots.backend_object(plot(1:5)).the_plot though I should probably make that return the plot object already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants