Skip to content

Problems with spacing between series on bar charts #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xarico10 opened this issue Jul 30, 2021 · 4 comments
Closed

Problems with spacing between series on bar charts #230

xarico10 opened this issue Jul 30, 2021 · 4 comments
Assignees

Comments

@xarico10
Copy link
Contributor

When plotting multiple series, the spacing between them isn't the same as MATLAB's and becomes harder to read and understand the graph.

x = [1980 1990 2000];
y = [40 50 63 52; 42 55 50 48; 30 20 44 40];
barh(x,y)
xlabel('Snowfall')
ylabel('Year')
legend({'Springfield','Fairview','Bristol','Jamesville'})

fig2plotly(gcf, 'offline', false);

Expected and generated (https://chart-studio.plotly.com/~xarico10/565/#/) plots:
Captura de Pantalla 2021-07-30 a la(s) 3 37 17 p  m
Captura de Pantalla 2021-07-30 a la(s) 3 37 32 p  m

As seen, the spacing between the values corresponding to 2000, 1990 and 1980 are more separated in MATLAB's plot, but not in the generated plot. It should be a bigger gap space between years.

Examples on plotting multiple series can be found on:
https://www.mathworks.com/help/matlab/ref/barh.html#d123e71912

@uzairmughal110
Copy link

By changing the following defaults, it works perfectly fine with me.
image

Code that I have used
x = [1980 1990 2000];
y = [40 50 63 52; 42 55 50 48; 30 20 44 40];
barh(x,y)
xlabel('Snowfall')
ylabel('Year')
legend({'Springfield','Fairview','Bristol','Jamesville'})

fig2plotly();

Output
Bar Charts

@xarico10
Copy link
Contributor Author

Great! Remember to create a pull request with the canges

@uzairmughal110
Copy link

Done..!!

@harshpurwar
Copy link
Contributor

Hi @xarico10 and @uzairmughal110
I believe if we do something like this it might be better and not affect other bar types... So inside updateBar.m

if strcmp(obj.layout.barmode,'group')
    obj.layout.bargap = 0.3;
else
    obj.layout.bargap = obj.PlotlyDefaults.Bargap;
end

And yes for me a value of 0.3 looks good. Anyway, bargap can't be more than 1.
image

I have already a PR in place that resolves this issue along with the BaseValue issue, so I will go ahead and close this issue.
image

@harshpurwar harshpurwar self-assigned this Aug 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants