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

add export table data to file #315

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

jguterl
Copy link

@jguterl jguterl commented Apr 14, 2023

This is a proposition to permit export of table data to file and shorten tikz files.

Usage:
p=plot()
x = collect(0:0.001:1.0)
y = @. 1-sqrt(1-x^2)
plot!(y,x,ylabel="Δq/qᵤ", xlabel="q_rad/qᵤ")
path = "/yourpath/here/"
Plots.PGFPlotsX.export2tikz(path * "delta_q.tex",p;relpath="figures")

@jguterl
Copy link
Author

jguterl commented Apr 14, 2023

That can be generalized to the various types of plots very easily.

@tpapp
Copy link
Collaborator

tpapp commented Apr 14, 2023

Can you please explain the use case? Yes, the tikz file would be shorter, but the same data ends up in another file, so what is the net gain?

@KristofferC
Copy link
Owner

Discussed a bit in #223.

@jguterl
Copy link
Author

jguterl commented Apr 14, 2023 via email

@KristofferC
Copy link
Owner

I don't really like this whole new export2tikz function. I think it should be possible to implement this as an argument to pgfsave.

The steps I am thinking are:

  • Each data source that can use an external file (for example Table) needs a modification to print_tex that allows it to save the data to a file.
  • When a file is saved to .tex with the external_data=true keyword argument:
    -- We set a global flag that we are currently saving with external data (and to what folder it is being saved)
    -- The data sources look at that global flag and instead of just printing the tex output, it also creates the data file.
    -- The naming of the data files is $(filename)_data_$(n).tsv where $n is a global counter.
    -- Before saving the file, all previous files of that name pattern above are removed (need to be a bit careful here, should probably add a header or something to do file which is checked so we don't remove user files).

That way, the only change a user has to do when exporting with separate data files is to add the ; external_data=true keyword to pgfsave.

@jguterl
Copy link
Author

jguterl commented Apr 14, 2023 via email

@jguterl
Copy link
Author

jguterl commented Apr 14, 2023 via email

@KristofferC
Copy link
Owner

Not really, but Plots allows you to get the underlying object which could be passed to pgfsave for example. Or savefig (or whatever Plots uses to save plots) could pass keywords down to the backend (maybe it already does).

@jguterl
Copy link
Author

jguterl commented Apr 14, 2023 via email

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

Successfully merging this pull request may close these issues.

3 participants