piermorel / gramm

Gramm is a complete data visualization toolbox for Matlab. It provides an easy to use and high-level interface to produce publication-quality plots of complex data with varied statistical visualizations. Gramm is inspired by R's ggplot2 library.
MIT License
782 stars 221 forks source link

Symmetrical jitter & highlighting plot elements #79

Open wildetudor opened 5 years ago

wildetudor commented 5 years ago

I very much hope this is the last time I bother you on here, Pierre. If I may, just a couple more questions:

1) I have several data points at each of several quantised levels, and I'd like to plot these as a dot plot (before adding other layers on top). The MatlabExchange script I was using previously (Univarscatter) was plotting points situated at the same level equidistantly about a central x value, regardless of the jitter width: 29-01-2019 16 10 49

Since I've now migrated all my plotting to gramm, I was hoping to obtain more or less the same with geom_jitter, but I get randomly non-equidistant points: 29-01-2019 16 24 01

Reducing the width doesn't help. Is there a way to make the jitter more systematic/symmetrical?

2) On this scatter plot, I'd like to highlight certain data points by making the marker larger or of a different shape, as in the UnivarScatter plot above. Can this be done, either with gramm or in parallel to it?

3) Similarly, I'd like to highlight the median on my violin plots. Adding stat_boxplot would be overkill - I'd like to just add a horizontal line (again, as in the plot above). Using Matlab commands ( line() ) prior to g.draw() seems to make a mess.

Thank you so much!

piermorel commented 5 years ago

Hi Tudor,

No bother ;) Though I'm afraid today won't be as useful.

  1. Actually here the answer is easy, but sad : gramm doesn't have this functionality... geom_jitter can only do a random jitter of the points. That said, since there is some existing file exchange code that does that (and it seems very well documented), it probably wouldn't be overly hard to add as a functionality to gramm as a new geom ! I might check it out myself, but you are welcome to try too... that might be faster !

  2. That's not an easy one for sure. It could be relatively easy to highlight a point by shape by adding a 'shape'argument to gramm as you would with color... but then the problem is that the point is considered separately by all functions (stat, but also jitter). Using update() could maybe get around the issue for stat but that's not super satisfying.

  3. For the median line, stat_boxplot followed by a removal of the box seems to me like the easiest option sadly. Median display is part of stat_summary but it can't draw lines, just points...

wildetudor commented 5 years ago

Thank you PIerre. It seems to me the best plotting solution (for someone who's not a Matlab pro) is to combine features from various functions, but unfortunately this is exactly what's challenging in this case, given gramm's class/objects which apparently don't easily interface with Matlab plots that are elseway produced.

I think for now I'll just do in gramm what can be done in gramm, and use 'old' methods for all else, rather than try and improve one by means of the other :)

Thanks again, I really appreciate it!!