Julia alternatives to Matplotlib?

No bro, at least with the default backend (GR) of Plots.jl, there’s no SVG output

That’s not true:

julia> using Plots

julia> plot(rand(10))

julia> savefig("random_plot.svg")

julia> Plots.backend()
Plots.GRBackend()  

(@v1.5) pkg> st -m Plots GR                                                                                                   
Status `C:\Users\ngudat\.julia\environments\v1.5\Manifest.toml`
  [28b8d3ca] GR v0.51.0 
  [91a5bcdd] Plots v1.6.0
5 Likes

I haven’t said anything about Makie. I just put up Gadfly as a possible alternative that fits the requirement. Feel free to contribute more alternatives…?

2 Likes

GMT, through GMT.jl, lets us virtually configure everything in a plot.

GMT certainly looks like a very extensive and powerful library. On the other hand, to me it also looks quite hard to use with a complex net of sub programs. The power to “configure everything” is not what I was talking about, almost every plotting tool has that. You can configure everything in matplotlib as well, but to get to good results you often just have to configure way too many things manually, especially with layouts.

2 Likes

In that case I should be covered. I meant to say that interactivity features are useful also for research.

subplot is very powerful with lots of nice defaults. What do you find more complicated in it than, Plots.jl, for example? E.g. this plots a 2x2 panels

subplot(grid=(2,2), panels_size=8, region=(0, 100, 0, 80), margins="5p", autolabel=true, col_axes=(bott=true,), row_axes=(left=true,), axes="wstr", name="panels.pdf")
        subplot(:set)
        basemap(region=(0,80,0,50))
        subplot(:set)
        plot([50 40], marker=:circle, mc=:red)
        subplot(:set)
        plot([50 40], marker=:square, mc=:green)
        subplot(:set, panel=(2,2))
        plot([50 40], marker=:star, mc=:blue)
subplot(:show)

I really don’t want to get into a comparison of layouting syntax or capabilities here, I was merely motivating why I work on a Julia-based plotting package if there are others out there

3 Likes

I’ll bite :smiley: :

dat = randn(200, 4) .* [1 2 3 4]
histogram(dat, layout = (2,2), link = :all)

Skærmbillede 2020-08-25 kl. 13.58.15

2 Likes

The issue is not that anyone is likely to hold you accountable in academia/research if you work a bit on plotting libraries. That’s how they most of them are actually written.

It’s just that you pay the opportunity cost of using that time for something for which you are actually rewarded, either directly or indirectly. Plotting software per se is financed in very rare cases, eg ggplot2 by RStudio.

I’m not disagreeing with that, I was just responding to this particular statement:

1 Like

I just renamed this topic from “Julia equivalent of Matplotlib?” to “Julia alternatives to Matplotlib?” which I think better expresses what I’m looking for, but invalidates some of the comments.

3 Likes

No worries, cache invalidation is a hard problem.

9 Likes

Not true if you use JuliaInterpreter, which is written in Julia but runs on two turtles and a sloth, neither of which is a programming language.

27 Likes

OK, I could have made my example smaller but not a 2-liners :slight_smile:
… but it can play geo-tic-tac

subplot(grid="3x3", dims=(panels=(5,),divlines=(1,:dashed)), axes=(axes=:lrbt,), margins=0, savefig="tictactoe.png")
    coast(region=:global, proj=(name=:Ortho, center=(30 ,30)), land=:red, B=:g, panel=(1,1))
    coast(region=:global, proj=(name=:Ortho, center=(120,30)), land=:red, B=:g, panel=(2,2))
    coast(region=:global, proj=(name=:Ortho, center=(210,30)), land=:red, B=:g, panel=(3,3))
subplot(:show)

13 Likes

well played :slight_smile:

2 Likes

I also took your post to be about saving files, so perhaps you were not as clear as you intended. Regardless, even if you were perfectly clear, this kind of antagonism is completely unwarranted.

13 Likes

Where did they make fun of your post? The replies you quoted were perfectly fine and helpful.

By the way, calling people ‘bro’ and ‘mate’ doesn’t come across as friendly.

12 Likes

I was just negating what I took as a mistake, no rudeness intended. I’m sorry if you felt it like that. That being said, I still think you are wrong. In Atom:

julia> using GR

julia> inline()
"svg"

And when I look at the aspect of the plots in the plot pane, definitely they are like the SVG output, not like PNG, e.g:

x = randn(1000); y = randn(1000);
plot(x, y, ".")

Screenshot of the plot pane (identical to the result of savefig("scatter.svg"), although svg images cannot be attached in Discourse):
scattersvg

Result of `savefig(“scatter.png”) - points are made nearly invisible in the process of rastering:

9 Likes

This post in only about the (im)possibility of Pure Julia plotting, so feel free to ignore. As I said previously it’s not important, as also an impossible goal (also in e.g. Python).

None of the its three backends are Julia only, i.e. in the end e.g GLMakie.jl will use GLFW → GLFW_jll a wrapper for C code.

Here you’re closer (I only see Julia code used), and plotting to the terminal is going to be the only “Pure Julia” in a practical sense (for GUI not possible, unless Julia abstracts over GUI libraries, I believe not done, nor wanted, web GUIs may be an exception), except you rely in Julia itself, and e.g. utf8proc written in C. E.g. utf8proc could conceivably have been written in pure Julia, and maybe even libuv, but at some point you’ll have to do I/O to the screen and it’s just not possible in pure Julia (unless we get “boot2Julia”, running baremetal, no OS, not what you want).

Gadfly seems to be pure Julia, but it in some sense doesn’t plot to “the screen”, only to a file (or for the example in docs I tried). Yes, this file gets to the screen, as it fires off your web browser (most likely written in C++, in a sense a huge library) displaying the “temporary” file it made (or not? I do not see them going away after closing the web tab, and /tmp may only get cleared on restart, or not).

File I/O is abstracted by Julia, unlike GUI stuff, with the “exception” of display() on that file.

This is clearly problematic since the firmware for the HDD/SSD is (probably) not written in Julia either.

5 Likes