Skip to content

Conversation

@isentropic
Copy link
Member

Dear all,
here is the first attempt at making gnuplot (gaston) plots backend. Still very early stage, still testing, too many things remain, but it feels like gnuplot can be a good backend as there have been no hacks implementing it so far.

Please test it like (naturally need to have gaston and gnuplot working beforehand)

using Plots; gaston()
plot(1:10, xlab="gnuplot is not bad at all", xguidefontsize=15, ylab="notbad", yguidefontsize=5, tick_direction=:out, guidefontfamily="Serif")

image

plot(
       plot(1:10, xlab="gnuplot is not bad at all", xguidefontsize=15, ylab="notbad", yguidefontsize=5, tick_direction=:out, guidefontfamily="Serif"), plot(sin.(1:100))
       )

image

Not many things work, in fact, most don't. But I think there is potential to this as it behaved very nice so far. Only tested in repl, but jupyter has to work too. Waiting for reviews from @mbaz
q

function _update_plot_object(plt::Plot{GastonBackend})
end

function _show(io::IO, ::MIME"image/png", plt::Plot{GastonBackend})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saving figures would be done through this function

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbaz it would be really helpful if you could help me fill this cuntion correctly

@codecov
Copy link

codecov bot commented Dec 3, 2020

Codecov Report

Merging #3177 (87b5b1d) into master (c857d59) will decrease coverage by 1.26%.
The diff coverage is 0.54%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3177      +/-   ##
==========================================
- Coverage   63.76%   62.50%   -1.27%     
==========================================
  Files          25       26       +1     
  Lines        6450     6641     +191     
==========================================
+ Hits         4113     4151      +38     
- Misses       2337     2490     +153     
Impacted Files Coverage Δ
src/backends.jl 68.29% <0.00%> (-2.05%) ⬇️
src/backends/gaston.jl 0.00% <0.00%> (ø)
src/init.jl 100.00% <100.00%> (ø)
src/recipes.jl 57.36% <0.00%> (-1.26%) ⬇️
src/layouts.jl 63.34% <0.00%> (-0.75%) ⬇️
src/axes.jl 77.20% <0.00%> (-0.73%) ⬇️
src/backends/gr.jl 89.56% <0.00%> (-0.10%) ⬇️
src/utils.jl 56.11% <0.00%> (ø)
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c857d59...87b5b1d. Read the comment docs.

@BeastyBlacksmith BeastyBlacksmith marked this pull request as draft December 3, 2020 07:57
@isentropic
Copy link
Member Author

More things work now

linetypes = [:path :steppre :steppost :sticks :scatter]
n = length(linetypes)
x = Vector[sort(rand(20)) for i = 1:n]
y = rand(20, n)
plot(x, y, line = (linetypes, 3), lab = map(string, linetypes), ms = 15)

image

@isentropic
Copy link
Member Author

@mbaz I wanted to know if communication with gnuplot is possible? Basically
show commands in gnuplot repl

@mbaz
Copy link

mbaz commented Dec 4, 2020

@isentropic If you mean running arbitrary gnuplot commands, it's planned for the next version (mbaz/Gaston.jl#154)

As for show commands: Gaston (in my private devel branch, which will become 2.0) supports showing ascii, svg, png, sixelgd and canvas on the terminal (as text). Is that what you mean?

@isentropic
Copy link
Member Author

isentropic commented Dec 4, 2020

http://www.gnuplot.info/docs_5.4/Gnuplot_5_4.pdf
show command as in the docs. So back communication from gnuplot basically

@mbaz

@mbaz
Copy link

mbaz commented Dec 5, 2020

Oh! I thought you meant Julia's show, not gnuplot's. Sorry for the confusion.

This is not supported at the moment -- you can send commands to gnuplot using Gaston.gnuplot_send(), but Gaston does not read back the result. I plan to support this in the next version.

@isentropic
Copy link
Member Author

New stuff like axis keywords and stuff added. Comments are welcome

plot(histogram(randn(10000), yscale=:log10), plot(1:500))

image

@isentropic
Copy link
Member Author

Supported args and markers are written in backends.jl I think that this might be ready for some tests now. Can someone help do it? I was never good with tests and how to run them.
Also, @mbaz would you please write up the save function? I'm not sure what would be the right way to export the figures. I think it would be fairly easy, similar to display function

@isentropic isentropic marked this pull request as ready for review December 7, 2020 14:50
@isentropic isentropic closed this Dec 7, 2020
@isentropic isentropic reopened this Dec 7, 2020
@isentropic
Copy link
Member Author

how do i make this a draft? I presed complete review now its green again

@daschw
Copy link
Member

daschw commented Dec 7, 2020

I tested it and it works amazing (from the REPL) so far. Really nice effort! What are your plans? Do you want to keep working on this PR to add more features, or would you rather merge a first basic PR and continue working on new features in other PRs?

@mbaz
Copy link

mbaz commented Dec 7, 2020

@isentropic What do you need for the save function? Gaston already can save plots in multiple formats: https://github.com/mbaz/Gaston.jl/blob/master/src/gaston_save.jl https://mbaz.github.io/Gaston.jl/stable/introduction/#Saving-plots-1

Awesome work BTW!

@BeastyBlacksmith
Copy link
Member

how do i make this a draft? I presed complete review now its green again

"Convert to draft" is below the reviewer section

Copy link
Member Author

@isentropic isentropic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbaz Would you please look at these comments? For some reason the saving for pdf, latex, and txt works unexpectedly

end
end

function _show(io::IO, mime::MIME{Symbol("image/png")},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbaz Image/png I believe is for png figures, as gnuplot has a constant dpi I had add some scaling hacks here

"application/x-tex" => "epslatex", # NEED fixing TODO
"text/plain" => "dumb", # NEED fixing TODO
)
@eval function _show(io::IO, ::MIME{Symbol($mime)}, plt::Plot{GastonBackend})
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbaz, most of the terminals do not work properly and I do not know why. PDF for some reason produces weird output. Also, latex terminals complain about the file format.

@isentropic
Copy link
Member Author

@daschw Yeah, I think I need to polish up saving and some more plotting args like plot title and legend box positioning. Then perhaps it would cover the bare minimum for simple 2d plots. Later, I'm planning to add colorbar and 3d plots.

@isentropic
Copy link
Member Author

p = plot(rand(50,5), fontfamily="Serif", legendtitle="legend", leg=:outerbottomleft, title="titles are here")
image

a few more things work, I guess right now it is minimal working verion

@VarLad
Copy link

VarLad commented Dec 23, 2020

@isentropic Great work!
Any idea how long would it take to get it as functional as other backends?
Like, what percent do you think can Gaston backend provide for now, compared to the complete product?
Again, thanks for taking the time!

@isentropic
Copy link
Member Author

@clad26 I really wanted to have gaston as an invitation for new contributors really. It is an inferior backend that is very lean in codebase (300 lines only). I think people familiar with gnuplot in general will find it easy to contribute and improve on this. Right I would say that a lot of 2d plots work already, but 3d support is not here yet.

@VarLad
Copy link

VarLad commented Dec 31, 2020

@clad26 I really wanted to have gaston as an invitation for new contributors really. It is an inferior backend that is very lean in codebase (300 lines only). I think people familiar with gnuplot in general will find it easy to contribute and improve on this. Right I would say that a lot of 2d plots work already, but 3d support is not here yet.

Does it provide histogram yet?

@isentropic
Copy link
Member Author

Yeah it works

@isentropic
Copy link
Member Author

@clad26 if you are interested in this, let me know what features do you need the most

@VarLad
Copy link

VarLad commented Apr 25, 2021

@isentropic It'd be nice if this can be fully completed and merged as a part of plots

Since the artifacts are almost here, this might be good

You can tell me from where can I start implementing 3D and what in 2D is left, so that I can help too?

Also, I'm interested in the first plot time of Gaston+Plots with the latest version of Plots. It'd be nice if you can update the compat in https://github.com/isentropic/Plots.jl/tree/gnuplot

@isentropic
Copy link
Member Author

The important think that prevents me from merging this, is the lack of testing and community feedback. This was an experiment of mine to see if gnuplot can even work as a backend for plots. I'd hold off with implementing 3d. We need to test 2d suite for egregious bugs first (I cannot afford to do testing --- that is to use this on daily basis and see what is missing).

Regarding comPat, I'm not sure how to set this up, perhaps you could send a PR to this fork?

If you could assist with this backend, I'd be happy to see contribution

@t-bltg t-bltg added enhancement improving existing functionality help wanted labels Jul 5, 2021
@BeastyBlacksmith BeastyBlacksmith merged commit e58fdf9 into JuliaPlots:master Jul 5, 2021
@t-bltg
Copy link
Member

t-bltg commented Jul 21, 2021

@isentropic, we now have Gaston in the docs: https://docs.juliaplots.org/latest/generated/gaston 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement improving existing functionality help wanted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants