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
784 stars 222 forks source link

Explicit error bars #84

Closed pgratrex closed 5 years ago

pgratrex commented 5 years ago

Hey Pierre,

Firstly, I want to congratulate and thank you for your excellent package. The results are fantastic, and the documentation is extremely useful.

However, there is a feature that I am either unable to find or does not exist yet: explicitly declare error bars. I frequently deal with data that has already been binned into a single set of X and Y columns, with each data point having its associated error in a third column. Is there a way of passing this error to gramm so that I can use the 'line with shading' as seen in the stat_summary examples? Intuitively, I feel it should be possible to have something like:

g = gramm('X', energy_transfer, 'Y', intensity, 'E', error) ;

Many thanks again!

piermorel commented 5 years ago

Hi Paul,

Glad you are enjoying using gramm !

You can do exactly what you want using geom_interval(), and providing 'ymin' and 'ymax' in the initial gramm() call (you will have to subtract and add your error variable to y) . There should be an example of use in examples.m

pgratrex commented 5 years ago

Whilst you were typing, I realised that this was exactly the solution I was looking for. Glad that we agree.

Thanks again!