Invisible axes, labels, etc. with PyPlot?

x = 0:0.1:2π
y = sin(x)

plot(x,y)
ax = gca()

ax[:set_frame_on](false)
??
??

What else do I need to specify, in order to make everything but the plotted sinusoid invisible?

Have you looked at the Matplotlib documentation? The answer should be there, since PyPlot is just a wrapper around Matplotlib.

Try ax[:axis]("off"), that should remove all the borders and axis.

Working example:

Using PyPlot
x = 0:0.1:2π
y = sin(x)
fig, ax = subplots()
ax[:plot](x, y, “b-”, linewidth=2)
ax:axis`

2 Likes

You are right and I am deeply sorry for appearing lazy: I tried and found that matplotlib’s documentation is …simply too large. I also admit I got lost in the “mapping” between Julia and Python, as I am not myself a Python speaker.

MATLAB was crappy but relatively straightforward and I am sincerely looking to Julia for a MATLAB replacement. .

What is the best (=simplest yet powerful) package for plotting (say academic work, data visualisation for journal publication) ?
Thanks anyway for your time.

2 Likes

Thanks. I am in debt!

If you don’t want to do the translation yourself, I recommend using Plots.jl. Tom already did the translation, so instead you just have to know the Plots.jl docs. Besides, it also means you instantly know how to use like 6 other plotting packages, since Plots.jl’s commands just control them all.

2 Likes

You can remove the Subplots() and then just use the function axis directly instead of the ax stuff.

@mgiugliano: What is the best (=simplest yet powerful) package for plotting (say academic work, data visualisation for journal publication) ?

simplest yet powerful usage: Plots.jl
I agree with @ChrisRackauckas. In terms of usage: I suggest using Plots.jl - especially for those with a Matlab background.

Note: Plots.jl is (mostly) not a plotting package in itself. It is principally an easy-to-use interface for generating plots. For the actual plotting: you simply pick from one of the ~7 supported “backends”.

Plots.jl makes plotting in Julia lean more towards Matlab’s use model:

  • Plots.jl makes it quick & easy to perform REPL (cmd-line)-interative operations - helping to flesh-out what is needed to get your “scripts” up-and-running.
  • In other words: Plots.jl enables the quick-and-dirty methodology scientists/engineers often use to work-out their calculations.
1 Like

@mgiugliano: What is the best (=simplest yet powerful) package for plotting (say academic work, data visualisation for journal publication) ?

Choosing a “powerful” plotting package

I would say most of the backends supported by Plots.jl are of publication quality (except for UnicodePlots).

The trick is to either save to a vector format (.eps, .svg, …) or generate a bitmap with sufficiently high resolution.

In the end, your choice of backend will probably depend on the following:

  • Prefer a pop-up window to avoid finding an image viewer?
  • Is this a web browser window?
  • Need a GUI to pan/zoom into data, or get better coordinate readings, …?
  • Is the installation a pain? Does it work on all our platforms?
  • Is my plot type supported? (ex: pie chart, heat map, 3D plot, …)
  • Is the time-to-first-plot important? (if restarting Julia often)
  • Are the plot times too long when working with large datasets (> 1Gb).

The following page might help to pick the right backend: https://juliaplots.github.io/backends/.

My suggestion for academic work
Not knowing the details of your own work, I would suggest one of the following backends to Plots.jl:

  • PyPlot.jl: Has alot of functionality.
  • GR.jl: Fast, with much functionality - but no real GUI yet (just a single pop-up window).
  • InspectDR.jl: Fast (even on large datasets), with good, responsive pan/zoom interactivity (Sorry, biased here) - but limited to 2D plots.

Important: The neat thing with using Plots.jl is you can switch from one backend to another without having to re-learn anything. You just need to make sure the “backend” plotting package is installed.

You can also get a feel for the quality of the resultant plots by looking at the “examples” section of the Plots.jl documentation:
https://juliaplots.github.io/examples/pyplot/

3 Likes

@MA_Laforge You can also get a feel for the quality of the resultant plots by looking at the “examples” section of the Plots.jl documentation:

I should probably point out:
The “examples” section does not yet contain output for InspectDR (only PyPlot, GR, PlotlyJS, PGFPlots & UnicodePlots).

For examples of InspectDR output, check out the “Galleries” section at the top of InspectDR/README.md:

Link: https://github.com/ma-laforge/InspectDR.jl/blob/master/README.md

I would just add to the above by stating that I don’t think there is a ‘best’ package for plotting. Julia has lots of different plotting packages that are specialized for different uses, and picking a ‘best’ package is like picking the ‘best’ shoe or ‘best’ type of nail - it depends on taste, preference and what you want to use it for. (My excuses to anyone who finds this list unrepresentative). Gadfly is great if you love the grammar of graphics interface. PyPlot has tons of functionality, is really stable and great if you are migrating from Python. PlotlyJS makes beautiful plots and has really nice interactivity and works well for the web. GR is very fast and makes clear plots. PGFplots is great for LaTeX-lovers. Plots is a slightly different beast from these - it aims to be a unified framework for calling other plotting packages (it sadly doesn’t work with Gadfly), which should especially be ideal for package authors that want to define generic plotting capabilities for their types without being tied to a single plotting package; something that seems to me to be essential in a landscape with so many good options for plotting.

It is a slightly tricky question to ask here, as there is a lot of religion about what is the ‘best’ plotting package. The only advice is to look at some plots and experiment with packages and find one that suits your needs.

2 Likes