Re: Sideways violin plots in one plot cmd?

Ethan A Merritt <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Organization University of Washington
Message-ID <1612266.BAagSR0fno@stonelion>
On Friday, 14 August 2020 10:34:52 PDT Juhász Péter wrote:
> On Wed, 2020-08-05 at 23:46 -0700, Dima Kogan wrote:
> > A question. I'm looking at the violin plot demo page:
> > 
> >   http://gnuplot.sourceforge.net/demo/violinplot.html
> > 
> > It shows how to make a horizontal density plot using 'smooth
> > kdensity'.
> > 
> > Then it shows to to make a vertical density plot by plotting
> > horizontally into a table, and then plotting the table, with "using"
> > directives used to swap the axes. This works clearly, but is there a
> > way
> > to do this (vertical density plots) with a single plot command? That
> > would make my life much easier.
> > 
> > Thanks!
> > 
> > 
> > 
> 
> Well, recently at $work I used gnuplot to produce a sideways histogram.
> Because it had to be sideways, I had to resort to manually assembling
> the plot with the boxxyerror style, with an awkward preprocessing step.
> 
> This, and your question, gives me the idea that it might be worth
> adding a general 'transpose' option to some of the "clever" plot styles
> that produce non-trivial vertical plots (histograms and boxplots,
> mostly).
> 
> best regards,
> Peter Juhasz

"How to make a sideways plot" does seem to be a very
frequently asked question.  There may be some clever way to select
an x/y axis transposition in the general case, but if so I have not been
able to find it.  

The program was designed from the start to have a single 2D plot mode
with x always horizontal, and a single 3D plot mode with z always
perpendicular to to horizontal axis. It would be possible to introduce
a third plot mode with x vertical and y horizontal, but that would have
to essentially duplicate all the existing code in plot2d.c and graphics.c,
which I think is far too much effort and code for only a little gain.

It is easier to relax the restrictions on the 3D plot mode. 
Over time the program has gained the options

- "set view map"   reproduces the x-horizontal y-vertical 2D layout.
  This allow use of 3D plot styles but does not address the current request.

- "set view azimuth" relaxes the requirement that the z axis of a 3D
  plot must be perpendicular to the horizontal.  This allows 3D view
  conventions such as altitude-azimuth that were not previously possible.

- "set view projection [xz|yz]".  These are new in version 5.4
 They do allow a "sideways" plot layout, with two drawbacks:
 1) it only supports the subset of styles in "splot" rather than "plot"
 2) the horizontal axis is z (not y), which is a bit confusing

I think there is room to build on this last idea in a couple of ways.

The 1st drawback could be addressed by extending more of the
2D plot styles to work with "splot".
Currently these styles work in projection:
	points lines vectors impulses 
	filledcurves/polygons (2D and 3D not quite the same)
	boxes 
	boxerrorbars (just added, conditional on #ifdef BOXERROR3D)

Smoothing is currently limited to csplines.
Adding kdensity smoothing to the 3D code would be easy, which 
might address Peter's current request.  But we will undoubtedly
continue to see requests for sideways histograms, boxplots, etc.
Those would not be so easy to extend to 3D.

The 2nd drawback may have a clever solution, although I do not
see immediately how it would work.  Would it be possible to hide
the x-is-now-y, z-is-now-x coordinate replacement at the input stage
so that the user doesn't have to worry about it?  How?

I have been thinking about adding a new demo to show that
"set view projection xz" can produce many "sideways" plot styles,
but haven't done much about it yet.   It needs to use some class
of data that legitimately benefits from the horizontal rather than
vertical layout.   Just turning an existing plot sideways is not
IMHO particularly useful.  Peter - would the plot you constructed
by hand be a good example to adapt?  If the combination
    set view projection xz
    splot ... with boxerror
doesn't handle it adequately, that would highlight where it would
be worth some additional work on the code. 

	Ethan




_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.