Git Product home page Git Product logo

piermorel / gramm Goto Github PK

View Code? Open in Web Editor NEW
759.0 59.0 217.0 38.29 MB

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.

License: MIT License

MATLAB 66.82% HTML 30.76% TeX 2.43%
matlab visualization stats plot data-visualization statistics

gramm's People

Contributors

ajrock avatar azabicki avatar guptasmith avatar jaapnieland avatar matthijscox avatar mxmarx avatar nicholas-schaub avatar piermorel avatar vijayiyer05 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gramm's Issues

subset and set_order_options

When I specify a subset and later want to use set_order_options with a manually specified order, I need to specify an ordering of the value after the application of the subset. I would expect that I can order the full set and that the subset is automatically applied to the ordering aswell.

Problem with update()

Hi,

First off, I think porting ggplot2 is a great thing and I can really see this being useful in the future.

One issue I have is with the update command when I run this block of code
g=gramm('x',Banded_random.Mat_Size,'y',Banded_random.Time,'color',Banded_random.Algorithm_type); g.facet_grid([],Banded_random.Band_percentage); g.geom_point g.axe_property('XScale','log') g.axe_property('YScale','log') figure('Position',[100 100 800 400]); g.draw();

everything works well and a plot shows up. However, if I close the figure and run g.draw() again, I get a warning

` >>g.draw()
Warning: Multiple draw() calls need update() calls

In gramm/draw (line 103)
ans =
gramm with properties:
legend_axe_handle: [1×1 Axes]
title_axe_handle: []
facet_axes_handles: [1×5 Axes]
results: [1×1 struct] `

and then running g.update() I get
>> g.update() ans = gramm with properties: legend_axe_handle: [1×1 Axes] title_axe_handle: [] facet_axes_handles: [1×5 Axes] results: []

which clears all my results. When I try replotting it after update I get

Error using axes Invalid axes handle Error in gramm/draw (line 409) axes(obj.facet_axes_handles(ind_row,ind_column));

Do you know if I am inputting things incorrectly or if this is an actual bug with the code?

Multiple plots ordering (foreground/background)

Hey again!
I've been working quite a bit with the .geom_hline function for limits and have noticed that for the lines created by this are always on top, even if the function is called after the main plotting function (like .stat_boxplot).

Is there a way to determine the ordering of the gramm plots so as to determine which would be in the foreground and which in the background? I'm painfully aware of how unintuitive this is to accomplish in MATLAB manually.

From looking at the code in .draw, I see that the hline/vline/etc. take place after the main plot (probably why they're on top) and that trying to mess around with the order of these parts for my own sake would probably end up in disaster, which leaves using uistack() for this purpose, this could probably be accomplished by using an array to decide the order of the graphical objects and then sending each one to the 'top'/'bottom' according to that order so they stack accordingly, but since this would require getting brand new input from the user, I'm not really sure how to implement it right now...

Differently sized subplots

First, I want to thank you for creating this incredibly useful toolbox. It is a huge improvement to MATLAB.

Second, I'd like to ask if there is a way to generate subplots of different sizes similar to the ones you'd get when using for example subplot(2,2,[2,4]) in base Matlab.

Thank you so much.
Best
Jana

stat_summary, geom solid_area: Undefined function or variable 'c'.

Small bug in stat_summary:


Undefined function or variable 'c'.

the line 3693 in gramm.m

h=fill([xci(2,:) fliplr(xci(1,:))],[yci(2,:) fliplr(yci(1,:))],c);

should be

h=fill([xci(2,:) fliplr(xci(1,:))],[yci(2,:) fliplr(yci(1,:))],draw_data.color);

Reproducable example:


clear g8
figure

load carbig.mat %Load example dataset about cars
origin_region=num2cell(org,2); %Convert origin data to a cellstr
%Create a gramm object, provide x (year) and y (mpg) data
%color data (region of origin) and select a subset of the data
g8=gramm('x',Model_Year,'y',MPG,'color',origin_region,'subset',Cylinders~=3 & Cylinders~=5,'size',5)
%Set appropriate names for legends
g8.set_names('color','Origin','x','Year of production','y','MPG','column','# Cylinders')
%Subdivide the data in subplots horizontally by number of cylinders
g8.facet_grid([],Cylinders)
%Plot raw data points
g8.geom_point()
%Plot summarized data: 5 bins over x are created and for each
%bin the mean and confidence interval is displayed as a shaded area
g8.stat_summary('geom','solid_area')
g8.draw() %Draw method

>15 colors in stat_density

Sorry, to trouble you again, but there seems to be a problem with the colors when using more than 15 grouping items in a stat_density plot.

This is from the gramm examples but changed from geom_line to stat_density and doesn't work anymore.

_load spectra.mat

%Here we create x as a 1xN array (see example above), and use a MxN matrix
%for y. Color applies to the M rows of y.
g18=gramm('x',900:2:1700,'y',NIR,'color',octane);
g18.set_names('x','Wavelength (nm)','y','NIR','color','Octane');
g18.set_continuous_color('colormap','hot');
g18.stat_density;
figure('Position',[100 100 800 450]);
g18.draw();_

Is there something I can do to make it work?
Thank you so much!

facet_grid documentation small mistake

'scale' can be set to either 'fixed', 'free_x',
'free_y', 'free', or 'independent' so that the scale of the subplots is respectively
the same over all subplots, x adjusted per columns of subplots ,
y adjusted per rows of subplots, x adjusted per rows and y per columns,
or x and y adjusted independently per subplot

(Unfortunately for me ;-) ) This should be the other way round. See the code of draw.m

case 'free'
                        temp_xscale='per_column';
                        temp_yscale='per_row';

update & geom_vline error

If I want to plot another vline after updating, it throws an error

figure
g = gramm('x',rand(20,20),'y',rand(20,20)')
geom_line(g)
geom_vline(g,'xintercept',0)
draw(g)

update(g)
geom_vline(g,'xintercept',1)
draw(g)

Results in error

Reference to non-existent field 'slope'.

Error in fill_abline (line 5)
ab.slope(end+1:end+l)=shiftdim(varargin{1});

Error in gramm/geom_vline (line 14)
    obj(obj_ind).abline=fill_abline(obj(obj_ind).abline,NaN,NaN,p.Results.xintercept,NaN,@(x)x,p.Results.style,p.Results.extent); 

The furthest I succeded with debugging: The field "abline" of ```obj(obj_ind)`` in geom_vline.m L14
is missing for the updated gramm object but not the original one (there it is empty, and a bunch of others as well). Hope that helps already.

Continuous Color for less than 15 values

When plotting less than 15 colors, but activating continuous colormode using set_continuous_color, gramm.draw() is overwriting this and deactivates it again.

The line 207 in @gramm/draw.m:

   %If we have too many numerical values for the color we
    %switch to continuous color
    if length(uni_color)>15 && ~iscellstr(uni_color) && (isnan(obj.continuous_color_options.active) || obj.continuous_color_options.active)
        obj.continuous_color_options.active = true;
    else
        obj.continuous_color_options.active = false;
    end

could be changed to a logical-or; something like this:

~iscellstr(uni_color)  && ( length(uni_color)>15 || (isnan(obj.continuous_color_options.active) || obj.continuous_color_options.active))

I hope this does not introduce issues further down the line.

Thanks again for the very well functioning toolbox!

Computing ci intervals using a custom function

For many types of data (e.g. with dependent or multi-level observations) standard methods of computing CI can be overoptimistic. It would be nice to be able to pass a function handle to stat_summary() to compute ci's more accurately in these cases.

Perhaps one option could be to pass a custom my_computeci function as an alternative to the calls to computeci
https://github.com/piermorel/gramm/blob/master/@gramm/stat_summary.m#L332
https://github.com/piermorel/gramm/blob/master/@gramm/stat_summary.m#L234

semi-transparent points

It would be great if geom_point() and geom_jitter() supported alpha, a bit like panel C and D in the attached figure :

3 copy

Editing the ylabel in plots generated with stat_bin

Hello,

thank you for this great toolbox!

Is there a way to alter the y label in histograms? For example if I use the defaults in stat_bin it reads 'count'. Is it possible to change this? I would expect it to be possible by calling set_names('y','mylabelhere') but it does not seem to be the case.

Text properties flexibility

I love this toolbox, it's fantastic and very simple to use, with one exception - in order to change the font size or font name of the axis+legend+titles in my graphs I am forced to write an external function to cycle through all the text objects in the figure which is redundant and messy.
Is there a chance to implement such a functionality in the future?

Weird Shading Shape with stat_fit()

On R2016a (windows, gramm 2.5), I get weird vertical bars of shading (in addition to the correct shading) when I plot a linear regression on 4,000 points using:
figure;
g = gramm('x', x, 'y', y);
g.stat_fit('intopt','observation');
g.draw();

The above code works for:
x=randn(4000,1);
y=x+randn(4000,1)/10;
However, when I use the data from the below link, the shading contains the (probably) correct margins, plus a vertical bar of shading that extends down to the x axis. The bar moves around between different renderings:
https://github.com/efwb001/random_public_files/blob/master/buggydata.m

Facet & Continuous Colorscale, multiple CLims

If you do facet_grid and have multiple continuous colorscales, they each are mapped on the full scale, instead of their respective domains.

See for example this code:

figure
g = gramm('x',repmat(1:10,1,20),'y',1:200,'color',1:200)
g.geom_line()
g.facet_grid([repmat({'1'},40,1);repmat({'2'},160,1)],[])
g.draw

Same thing for facet_wrap.

And here is a screenshot of the output.

screenshot from 2016-01-29 17 37 36

geom_line, group and stat_summary

Goal in R

In ggplot2 one can do the following:

ggplot(data.frame(x=rep(1:10,5), y =rnorm(50),group=sort(rep(1:5,10))), aes(x=x,y=y,group=group)) +
geom_line() + 
stat_summary(aes(group=NA),color='red')

Resulting in:
rplot

The same thing in matlab

The same thing in matlab:


        g = gramm('x',repmat(1:10,1,5), 'y',randn(50,1))%,'group',sort(repmat(1:5,1,10)));
        g.geom_line() 
        g.stat_summary()
        g.draw()

in gramm I don't think this is possible due to the missing stat_summary(aes(group=NA)) option.
I'm either stuck with connected lines (if I drop the group=group statement from the initial call) like this:

untitled
(the CI - lines are very faint but there. I did not want to change the call further).

or the stat_summary function tries to calculate the CI in one group (exactly as it should!).

untitled

I guess this is a limitation of the current implementation and I don't see a simple solution to it. Nevertheless I thought to post this here, maybe it helps in further development!
I still enjoy using the tool very much, keep up the good work (and the cheatsheet is superb!).

Support Categorical Variables

Hi, since MATLAB 2013b, there has been support for table and categorical, which provides a much richer way to organise statistical data for analysis. Ideally, gramm would be built around tables, but that would break backwards compatibility. Neverthless, it would be good to add support for at least categorical variables for the grouping variables. It almost works but breaks on line 1297:

text(2.5,ind_scale,num2str(uni_color{ind_color}),'Interpreter','none')

It is easy to fix, but there are other places where the assumption of double OR cell is made.

Plot limits for histograms?

Hey again,
I've been wondering if @piermorel (or anyone else reading this) might have an idea how to implement what I want to do using gramm:
I have a need to plot multiple histograms, of differing subsets and I've found that the configuration for "Superimposition of gramm objects on the same axes" suggested in the examples page works best for me.
So far I've managed to manipulate the code to suit my needs (I only use the top part of the gramm, with the subplots) but I'm still missing a method of plotting the spec limits for my distribution (as shown here by the vertical red lines).

When using just one gramm plot (and not a facet grid) I usually just add a line() plot from matlab according to the axis (and resize the gramm's axis, if the limits are out of bounds) but this is more difficult to achieve for a facet grid plot as it is hard to figure out which axis is the relevant one for each plot.

I thought about using a second gramm for the lines themselves but I couldn't figure out if it would work as an overlay or not.

Any tips?

Adjustable Legend

It would be really good if function would provide the option of moving the legend inside the plot to several position.

Installation instructions

Even though the (quite simple) installation instructions work as they are, I feel these a bit a dry especially for people only getting familiar with Git(Hub) and or MATLAB, even though if these seems very straightforward or trivial.

Feel free to disagree with this

Pre-2014b versions

Hi Pierre,

The lack of transparency on pre-2014b version is a bit annoying for people like me who use such versions.

I've just figured out that removing lines 1241-1248 (which sets the renderer to 'Painters') and adding the following statement at the top of the draw function (e.g line 28) works pretty well for me:

if verLessThan('matlab','8.4')
    warning('Pre-2014b version detected, forcing OpenGL to operate in software mode')    
    opengl software
end

Best,

Romain

Interpreter for labels and title

Would it be possible to change the interpreter of the labels and titles to 'Latex' or 'Tex'? This way we could also have subscript, superscript, and other LaTeX symbols

Alternate linestyles

Hey, so I've had another issue, namely with using linestyle for grouping datasets.
I've got 2 datasets which need to separated by linestyle, but the 2 first default linestyles solid line ('-') and dashed line ('--'), which, under the default legend size, look pretty much the same:
screen shot 2016-07-20 at 19 43 22

this is firstly a bug that needs to be taken care of, but more importantly it highlights the fact that the user does not have the freedom to specify the linestyles used at any point, so as to avoid this kind of mix-up.

Error in Subset Selection

Hi. I'm not sure if I'm doing this wrong or if it's a bug (probably the former).

I am trying to choose multiple subsets:

g=gramm('y', allData.ExcelExp_Short_ID12.intensities, 'x', allData.ExcelExp_Short_ID12.chemicalSpecies, 'color', allData.ExcelExp_Short_ID12.sampleName,'subset',allData.ExcelExp_Short_ID12.sampleNum <9 & allData.ExcelExp_Short_ID12.sampleNum >3 & allData.ExcelExp_Short_ID12.chemicalSpecies =="Propenal" & allData.ExcelExp_Short_ID12.chemicalSpecies =="PFBHA")

As you can see, I want to plot sample numbers between 3 and 9 and only the data from Propenal and PFBHA. If I choose to only plot "Propenal" it works fine. But when I add PFBHA as a second x category, I get the following error:

Error using cellfun
Input #2 expected to be a cell array, was double instead.

Can you assist with this? Perhaps even an explanation of the syntax for subset selection?

Thanks in advance!

Incorrect computation of stacked bar heights when x == color

From @matthijscox :

Looking into the stacked bars, I found some strange behavior if any of the groups matches the x data. The y-offset of the bars seems to be computed incorrectly in that case.
I'll see if I can easily fix that as well.

image

It's related to how you determine the height of the stack, using the dodge_x and the x position and the obj.firstrun, which in this particular case seems insufficient information to separate the stacks. This is thanks to my color group input being the same as x, which makes GRAMM cycle over all elements separately.

g.seat_names with LaTeX

g.set_names('x','\theta_1','y','\theta_2','z','\theta_3');

does not render the latex as the default interpreter does, any work around?

Label issue

Hi, I started to use gramm this week, so I am a quite noob :)
How can I move my label on the negative bars?

Thank you!
image

EdgeColor option (or switchable type 'edge_bar', 'bar' for geom_bar)

First of all: great toolbox, I love the possible customizations so far!

One thing I was trying to do is plot bars without a black edge using geom_bar. I noticed there are actually two bar types: 'bar' and 'edge_bar', the latter being called by geom_bar. The 'bar' has EdgeColor = 'none', but I cannot call it with geom_bar yet. Or am I not seeing an option or geometry somewhere?

I could solve this myself with a user input into geom_bar, for example 'edge', with a true/false setting. This than changes the input geom to plotci from edge_bar to bar, respectively (or internally changes the EdgeColor for stacked bars).

However, a generalization of this to other geometries could be to set the EdgeColor directly via the draw_data structure, for example for area's. But I don't know if that's valuable to anyone. Perhaps someone wants a black background with white edges? And I don't see an obvious set_xxx_options function for this.

[Feature Request] Notches in Boxplots

It would be very useful to be able to generate notches on gramm's boxplots. The MATLAB code to generate notches start around #2284 of MATLAB's stats/boxplot.m — though the drawing is done in stats/private/boxrenderer.m @drawLineBoxNotched

Support Simple Boxplots

If I only have x (group) and y(value) data, stat_boxplot does not work:

g=gramm('x',randi([1 2],50,1),'y',rand(50,1));
g.stat_boxplot();
g.draw

It should still generate a simple boxplot in this case, but the figure is blank.

iscategorical function is undefined

I have his bug:
Undefined function 'iscategorical' for input arguments of type
'double'.
Error in validate_aes (line 49)
if iscategorical(aes.(fields{k}))
Error in gramm/draw (line 80)
obj.aes=validate_aes(obj.aes);
I'm using Matlab R2013a
Regards

how to set_order_options for facet_grid?

The gramm_examples show how to change the order of e.g. bars with the line
set_order_options('x', {x_label_order})
This works perfectly for ordering x-values, color and lightness.

But with what do I replace the 'x' if I want to change the order of subplots in a facet_grid?

Example:
g(2,1)=gramm('x', data.x_values);
g(2,1).facet_grid(data.condition,[]);
g(2,1).stat_bin();
g(2,1).set_order_options( ???__ , {condition_label_order});
This produces little "subplots" of the data split up by the condition and they are currently in ascending order and I would like to have them in a given order.

It would be great if anyone could help me with that.
Thank you so much!!

Testing suite implementation

gramm seems well developed so far but I could not find any test for the package.

I might have missed something, but if I haven't, have you considered adding any?

Order with Facet_wrap

Hi, I'm a big fan of gramm!
One thing I was having trouble with, however, was setting the order of the facets with facet_wrap. My groups are often specified by a cell array, but facet_wrap orders them according to their sorted order (as if you had called unique() on them). I know for bar blots with categorical variables you can change the order with g.set_order_options and reset them to the order they were in the input, but is there similar functionality for changing the order of the facets, as you can do with the levels of factors in R?

Thanks!

Coord_flip + legend order

Hi Pier,

I was using the coord_flip functionality with geom_bar (I use bar plots a lot, I know).
When inspecting my results I was slightly confused, but then I noticed the data and the legend are not in the same order anymore.

It's a minor thing, but when presenting such plots, I'd like them to be as intuitive as possible. So I was wondering if there is a way to either mirror the coordinate system in X, or to flip the order of the legend items?

image

I now see that in the ggplot cheatsheet, the coord_flip actually does the transformation as I would expect (mirrored w.r.t. your output):
image

Code for later reference:

x=[ones(4,1);2*ones(4,1)];
y=[1:4, 1:4]';
c=x;
l=repmat({'smallest','small','big','biggest'}',2,1);
xc = arrayfun(@num2str,x,'unif',0);

clear g
g(1,1)=gramm('x',xc,'y',y,'color',c,'lightness',l);
g(1,1).geom_bar('dodge',1.5,'width',1.2);
g(1,2)=gramm('x',xc,'y',y,'color',c,'lightness',l);
g(1,2).geom_bar('dodge',1.5,'width',1.2);
g(1,2).coord_flip();

g.set_names('y','','x','');
g.set_order_options('lightness',0);
g.axe_property('YTick',[],'LineWidth',1,'YColor',[1 1 1])

figure('Position',[100 100 600 200]);
g.draw();

Continuous Color Limit

It would be helpful to have an option to prescribe a limit for continuous colormaps so that multiple figures can be compared side by side.

Post drawing changes

Hey again!
By now this is my third post on this project, and I have to say that ever since I first started using it over 6 months ago, I have grown more and more dependent on it rather than the normal MATLAB toolkit, so once again - great job with this project. You are doing a service to mankind (or at least the niche that does statistical analysis using MATLAB 😶).

In working this much with this toolbox, I have come to know some of it's limitations - a big one being the inability to make major changes to design after drawing a gramm object.
An example of my current use case - I want to save two versions of a specific graph, one with a title and another with no title.
If this were any normal figure, I would have simply drawn the figure sans title, saved the figure, added a title, then saved the figure again under a different name. In gramm this is much more difficult, as I cannot actually use an existing gramm object to completely redraw and rearrange a figure.
I have also tried copying the gramm object, opening a new figure, and drawing, but I understand now that the gramm object is connected to a specific figure, and cannot be simply copied around.

So I would like to know if you could think up of a workaround for this issue, namely to either be able to completely redraw a figure using an existing gramm object after adding a title and such or to simply copy an existing gramm object into a new one, which can be drawn separately from the original (perhaps this is already implemented but I didn't figure out how to do so?).

In any case, keep up the good work.

Problem with facet titles when saving figures as eps or changing resolution for export

I used your handy toolbox to remake some plots I previously made in R. I used facet-wrap for displaying relationships between variables block wise.
Everything went well until I exported the figures. In the eps file, the facet titles were suddenly in the middle of the respective facet plots. Using save yielded the same problem, so it's not the export that's causing the trouble. I tried several things and figured out that if I export it as Tiff without changing the resolution, everything is fine. However, the quality of these plots then is not acceptable, so I can't leave it like that, but changing the resolution messes up the title positions. Is there a way to fix/prevent it?
I first just copied the figure to pate it to the document I worked on, but then it didn't show the transparency, which I need so the regression lines are visible and don't melt into the points, as they have the same color.Here, it would be great if it were possible to change the color of the regression lines generated by stat_glm() (and also set single colors instead of maps for points, though there are workarounds here), but these latter problems are less important.

Thank you!

Best wishes,

Romy

Allow selection for stat_summary and stat_boxplot

Both stat_boxplot and stat_summary force grouping data in x and value data in y. It would be great if we could pass parameters so we could choose if x, y or color etc were used for value and group.

g.stat_summary('grouping','color','data','x')

Trying to run the examples... getting errors

Hi all, this toolbox looks great but I'm having trouble just running the examples from the example.m

For example, when I try to evaluate the "Methods for visualizing repeated trajectories" section I get:

Error using t (line 25)
Not enough input arguments.

Error in nanmean (line 7)
N = sum(~isnan(t), dim);

Error in gramm/stat_summary>my_summary (line 150)
uni_x=nanmean(x);

Error in gramm/stat_summary>@(dd)my_summary(obj,dd,p.Results) (line 108)
obj.geom=vertcat(obj.geom,{@(dd)my_summary(obj,dd,p.Results)});

Error in gramm/draw (line 488)
obj.geom{geom_ind}(draw_data);

Error in gramm/draw (line 52)
draw(obj(l,c));

I'm running r2014b. Since this toolbox is pretty new to me, I'm not sure what's the problem here. Hoping for some help -- would love to use this.

x/y/title label padding feature?

Is there such a feature/way, to easily adjust the padding of all labels (relative to their axes), rather than fiddling around with positions of the individual elements?

set_names error

Hi,

When I want to run the example file provided for gramm I get the below error:

Error using gramm/set_names
Method 'set_names' is not defined for class 'gramm' or is removed from MATLAB's search path.

Error in gramm (line 182)
set_names(obj);

Any thought to solve it?

I use MATLAB 2017.

tutorials and documentation

pierre, thanks for your work on this really fantastic toolbox - and making it available here. we've started using it in my lab and it has quickly proven to be super-useful.

i have also been encouraging colleagues to re-think they way they do their plotting in matlab with gramm.

you mentioned in a separate thread that developing some tutorials + walk-throughs and a bit more documentation is a priority (but potentially v time consuming). i thought i'd open this up to get your and other people's ideas about what would be most useful, to prioritise where i/we could best contribute...

Add flag for continuous color

currently continuous color is activated when there are more than 15 categories.

It would be nice to be able to manually activate continuous colors. In earlier versions you could manually set g.continuous_color=1 (albeit with some bugs in plotting).

Log Scaled Axes

Is there a way to use log scaling on axes? I haven't found one yet, and none of your examples seem to have them.

set_continuous_color with multiple figures

First of all, as always: Great work, this tool is invaluable!

If I run this script:

figure
g = gramm('x',1:20,'y',1:20,'color',[ones(1,10) 1:10 ])
geom_line(g)

facet_grid(g,[ones(1,10),2*ones(1,10)],[])
fig(g,[1 1 1 2*ones(1,10-3),3*ones(1,10)])
set_continuous_color(g)
draw(g)

I get the error

Error using matlab.graphics.axis.Axes/set
While setting property 'CLim' of class 'Axes':
Value must be a 1x2 vector of numeric type in which the second element is larger than the first and may be Inf

Error in caxis (line 80)
            set(ax,'CLim',arg);

Error in gramm/draw (line 726)
            caxis([mi ma]);

Error in gramm/draw (line 125)
        obj{ind_fig}.draw();
 
80              set(ax,'CLim',arg);

In Line 726 and 885 (after you fix L726)

Because I have a figure where the color limit is [1,1] and matlab does not like this. Please note that the first error does not occur if the limit is [0,0] (i.e. caxis([0,0]) works), but then the error at 885 still persists.

My current workaround:

replace in draw.m Line 885 and Line 726

        mi = min(min(obj.plot_lim.minc));
        ma = max(max(obj.plot_lim.maxc));
          
        if mi ~= ma
            caxis([mi ma]); % in L726
            set(ca,'CLimMode','manual','CLim',[mi ma]); % in L885
        end

But then I still get the not-useful colorbar legend. But it works :)

More general: I think the problem is, that set_continuous_color is defined for all figures, but should be defined for a single figure, or the obj.plot_lim.minc/maxc should either be over figures, or have default 0,0.

show significance stars

It would be fantastic if, together with stat_summary or some of the other stat functions, inferential statistics could be plotted. The easiest would be to automatically plot little stars (e.g. https://nl.mathworks.com/matlabcentral/fileexchange/39696-raacampbell-sigstar) depending on the outcome of a predefined test - most commonly a t-test against zero within each group of data, or paired tests between values of x (or even between columns).

I don't think it's a feature in the original R-ggplot2 - however, I think it would be extremely useful to generate plots that are even closer to publication-ready.
Thanks for coding up this great project!

Feature wishlist

Hi Pier,

Personally, I had the wish for some extra features (do you have a general wish/todo list somewhere?):

  • Facet axes spacing/margin options (I wanted tighter custom spacing, per direction customizable).
  • Vector/quiver plots (these I use a lot, and I have custom patch function for this now).
  • Continuous size scale (also nice together with the vector headsize for example)

The axes spacing and margins seemed to be hardcoded right now, so that one looks quite hard to change.

The vector plots would require an additional input interface, like 'xend' and 'yend' indicating the end of the vectors. Or alternatively you could use a length input 'dx', 'dy'.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.