On Fri, Apr 8, 2016 at 3:44 AM, Daniel Carrera <[email protected]> wrote:
> Hello, > > I was looking through the API for Plots.jl > > http://plots.readthedocs.org/en/latest/#api > If you look just above that, note that I put a big warning that this section of the docs need updating. Personally, I hardly ever use those mutating methods; but some people prefer that style, so I make it available. > Maybe I'm the only one, but I think all those exclamation marks are a bit > extraneous and feel like syntactic noise. > It modifies a plot, and so follows Julia convention. Anything else is likely to induce confusion. > I have been following Plots.jl because I'm interested in plotting. My use > of Julia comes down to either making plots, or post-processing data so I > can make a plots. I get the idea from Plots.jl that functions that end in > an exclamation mark are supposed to modify an existing plot. So you get > things like: > > plot!(...) # Add another plot to an existing one. > title!(...) > xaxis!("mylabel", :log, :flip) > xlims!(...) > xticks!(...) > If you don't want to plot like this, then don't! There's a million ways to produce the same plot. If you want to put all your commands in one line, this will work: plot(rand(10), title="TITLE", xaxis = ("mylabel", :log, :flip, (0, 20), linspace(1, 10, 20))) [image: Inline image 1] Plots figures out that log is the scale, (0,20) is the axis limits, and linspace(1,10,20) are the tick marks, which reduces a ton of clutter (not to mention you don't need to remember a complicated API). One of the key goals of Plots is that you can use whatever style suits you. (and feel free to open issues if there's something that you think can be more intuitive) > In PyPlot, all commands edit the current plot unless you explicitly call > `figure()` to create a new plot. You can also use clf() to clear the > current plot. I think this is something that PyPlot / Matplotlib get right. > We can agree to disagree on this point. It's clunky and error-prone. Quick tip: you can choose to reuse PyPlot windows by default if you want: # these will effectively call clf() before each command > using Plots pyplot(reuse = true) > plot(rand(10)) > plot(rand(10)) > plot(rand(10)) - Tom
