JuliaPlots / Plots.jl

Powerful convenience for Julia visualizations and data analysis
https://docs.juliaplots.org
Other
1.83k stars 354 forks source link

Supporting PGFPlots.jl #134

Closed pkofod closed 8 years ago

pkofod commented 8 years ago

As proposed in #133 it would be nice to support the PGFPlots-interface over at PGFPlots.jl.

Is it something you'd be willing to throw some time at @mykelk, or did you just want to add it as a "wanted feature"?

Edit Hijacking my own thread to track missing features I've identified, and need to add:

tbreloff commented 8 years ago

This is my first time looking through PGFPlots. Is there a compelling reason why this would be a preferred backend to PyPlot? It seems like a similar feature set. Is it better for research publications?

KristofferC commented 8 years ago

You can export the plot commands to a .tex file and include it in your main .tex document. It will then inherit all your latex font properties and stuff. It makes the style of the plot inherit the style of the publication in an almost unbeatable way.

tbreloff commented 8 years ago

Thanks @KristofferC... that's enough of a reason for me.

Does anyone have the capacity to take this on? Looking through the examples it seems like it would be a pretty straightforward implementation. Most of the logic could likely be called from the display/writemime methods... using the plotargs and seriesargs fields in a plot, just make the relevant calls to PGFPlots. Then wrap png/tex generation.

I could make a one-time pass to set it up, and then hopefully someone with PGFPlots experience can fill in the details. Anyone? Anyone? Bueller?

pkofod commented 8 years ago

I have quite some experience with PGFPlots (and love it), but not the PGFPlots.jl interface. As I would like to have this back-end available, it is only fair I accept some of the work load. However, I have no idea how Plots interact with backends nor do I have any idea how PGFPlots.jl implemented, so I would have to spend some time scanning through both before I can contribute.

tbreloff commented 8 years ago

I'm currently working on re-design of the backend setup and initialization. At the same time I'm preparing a template for a PGFPlots backend. Please wait until I push up the changes I'm working on before anyone starts work on this.

mykelk commented 8 years ago

Cool. You don't necessarily have to use PGFPlots.jl, you can just write your own stuff that spits out tex. If you do that, then you might want to use TikzPictures.jl (which PGFPlots.jl also uses) to handle the display. The output looks pretty nice. If you include equations, they get formatted properly by latex. Although my focus is on PGFPlots.jl, I'm happy to answer questions on how it might help support your project.

tbreloff commented 8 years ago

Is there a reason not to use PGFPlots.jl? I assume it should make the implementation easier?

pkofod commented 8 years ago

I would prefer pgfplots, as it already has functionality similar to the other backends. We want a backend, not have to write plotting packages from scratch.

mykelk commented 8 years ago

Can't think of a good reason not to.

tbreloff commented 8 years ago

Ok I just pushed up a pretty substantial commit to the dev branch. @pkofod if you'd like to give it a go, I highlighted the method where you'd probably call most of the code: https://github.com/tbreloff/Plots.jl/blob/dev/src/backends/pgfplots.jl#L87-L90

You should just do a dump of the Plot fields that I reference in the comments, and you'll probably be able to figure out what to do without much help. If you get stumped let me know.

pkofod commented 8 years ago

Thanks! Ill have a look and a go at it

pkofod commented 8 years ago

Don't worry, I'll get to it ;)

tbreloff commented 8 years ago

Just curious @pkofod ... were you still planning on tackling this project?

pkofod commented 8 years ago

Sorry, I got hung up in other projects, and forgot. I'll take a look at it at the beginning of next week.

pkofod commented 8 years ago

Before throwing too much time after this, I have a worry. Is it a problem that PGFPlots is GPL-licensed? I'm wondering if the "intimacy" between Plots.jl and PGFPlots.jl (and ultimately) PGFPlots might be on the border of what GPL allows if Plots.jl is supposed to be non-GPLed. (https://en.wikipedia.org/wiki/GNU_General_Public_License search intimacy). Any thoughts/knowledge here? @mykelk did you consider this when making PGFPlots.jl?

tbreloff commented 8 years ago

Thanks for considering this @pkofod. Certainly I don't want anything in Plots that is GPL. The other option is to add the backend code in PGFPlots.jl, and making the optional dependency the other way around.

sglyon commented 8 years ago

I'm not an expert, but I'm almost positive you can interface with GPL code from an MIT licensed package. I think you are extra safe here because you aren't even distributing any of the GPL code

pkofod commented 8 years ago

Okay, just erring on the side of caution here. It seems you are right ^1, at least according to this answer: http://programmers.stackexchange.com/questions/110380/call-gpl-software-from-non-gpl-software where the case is releasing a GUI to a command line program under GPL. That is good news then.

mykelk commented 8 years ago

There is no problem. PGFPlots.jl and pgfplots are two separate pieces of code. The pgfplots code is invoked through command line calls to lualatex, which then uses pgfplots.

pkofod commented 8 years ago

:+1: I will work on implementing PGFPlots in Plots

pkofod commented 8 years ago

Paper tech lart

I'll do a PR when I've got a few line types working

tbreloff commented 8 years ago

Cool... Glad to see you're working on it!

On Mar 15, 2016, at 8:55 AM, Patrick Kofod Mogensen notifications@github.com wrote:

Paper tech

I'll do a PR when I've got a few line types working

— You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/tbreloff/Plots.jl/issues/134#issuecomment-196805659

pkofod commented 8 years ago

Finally got around to it. I'm just the glue though! You guys already did the hard work. more

tbreloff commented 8 years ago

@pkofod... feel free to submit a PR now with what you have. You can label it WIP so I won't merge until you're ready, and if you push new commits onto that branch it will automatically add them to the PR. This is a nice way to discuss implementation details while you're still working. Thanks again!

tbreloff commented 8 years ago

I get an error from IJulia:

Error saving as SVG
could not spawn `lualatex --enable-write18 --output-directory=. tikzpicture`: no such file or directory (ENOENT)

I'm not sure if this is a dependency issue with PGFPlots.jl?

pkofod commented 8 years ago

What did you execute?

tbreloff commented 8 years ago

Oh sorry... it does that for everything I run (unless it errors in code before that call). plot(rand(10)) will trigger the error.

pkofod commented 8 years ago

Can you call lualatex from your terminal?

tbreloff commented 8 years ago

Installing it now... I was more wondering whether this should be handled either as part of Pkg.build("PGFPlots") or at least showing a clear warning that it won't work without an external dependency. I see now that he discusses dependencies in the PFGPlots docs.

tbreloff commented 8 years ago

This is turning out to be more complicated than I expected :(

I couldn't get anything to work through ubuntu's apt-get, which is apparently a known issue, so now I'm trying to install using install-tl-ubuntu as suggested by someone.

mykelk commented 8 years ago

Yeah, install-tl-ubuntu is the way to go. You will also need pdf2svg, so you should do sudo apt-get install pdf2svg if you don't already have it. The downside to PGFPlots.jl is that it requires a somewhat recent version of latex, but the plots are so beautiful once you get it installed.

tbreloff commented 8 years ago

Thanks for the confirmation @mykelk... is there any possibility that PGFPlots.jl can help the installation process to be cleaner? Or is it up to the user to figure it out for themselves? Will it be possible to test on travis?

tbreloff commented 8 years ago

I'm looking at your travis/tests now... I see you do use apt-get to install? Maybe I should try that again?

mykelk commented 8 years ago

@tbreloff you might want to try it again. I would love for the install process to be cleaner. At the very least, it should give some kind of warning about the system not having the right dependencies. It is tempting to have the package install latex automatically, but unfortunately, it is huge. If there was a nice minimal version of it that could be used in isolation that would support pgfplots and tikz, that would be great. The folks maintaining juliabox nicely include all the dependencies, so if you want to try PGFPlots.jl out, you can go over to juliabox.

tbreloff commented 8 years ago

I don't think I'll be able to easily try to install via apt-get: https://github.com/scottkosty/install-tl-ubuntu/issues/21

I finally got a line plot to work! For reference, these are (I hope) all the commands I needed:

cd /opt/
git clone git@github.com:scottkosty/install-tl-ubuntu.git
cd install-tl-ubuntu/
sudo ./install-tl-ubuntu
sudo apt-get install pdf2svg
sudo apt-get install xzdec
. /etc/environment 
pkofod commented 8 years ago

Annoying that it has to be so much work! At least it works now. I'm pretty sure it worked almost out of the box after my Ubuntu 15 reinstall

tbreloff commented 8 years ago

closing in favor of meta-issue