You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@chriddyp, thoughts? This is a common one, especially for heatmaps/contour plots. Here are a couple of ways we might implement this:
use a setter function (we're sort of opposed to this one since it's less declarative, less intuitive where it can be used. I.E. should this be a method for a Figure or Layout?)
have users just use fig['layout'].update(width=500, height=500, autosize=False)
throw it in the plot call, py.plot(fig, equal_axes=True)
I'd probably lean towards better documenting (2), but would consider (3). In addition, it would probably be a good idea to write in some logic that sets auto*=False whenever the appropriate keys are properly filled in, e.g., both widthandheight.
@arsenovic, it seems like you were maybe thinking of (1), do either (2) or (3) work for you?
it may be too greedy, but ideally you can have the graph auto-sizeable, but retain squareness. so whenever one width or height changes the other does too.
of the above options (3) is nice. (2) is a no so good, because the concepts of aspect ratio and size should be independent.
Where dimension could have "ratio", "pixels". We'd keep "autosize" to mean absolutely let Plotly chose the dimensions, i.e., you wouldn't get the requested aspect ratio unless "autosize": false.
Interesting, we can't do this now but it could definitely be a useful feature. Also seeing @arsenovic on here (howdy!) reminds me we'll need something similar for axes, if you want to enforce a particular aspect ratio as you zoom around - like for smith charts and maps.
The other thing I've been pondering re: autosize is some sort of responsive mode, where the fonts, margins, line widths, marker sizes... get adjusted as the size changes. Maybe linearly, (in the minimum dimension?) maybe something more sophisticated. Would be useful for publishers who want a responsive layout (they'll have to resize their iframe in javascript but then we can redraw the plot appropriately). Thoughts?
Hi...I would like to help implementing solution # 3 in 2nd post, this one:
3.throw it in the plot call, py.plot(fig, equal_axes=True)
So would it be possible if some one more familiar with the code let us know a good point to start to implement this option in the plot function? It would be great if you point us in the right direction.
@dab3-2014 - I think we're going to stay away from #3 but instead for people to set width and height in layout. My thought is that setting the size and the aspect ratio is setting the same number of things as setting the width and the height, so I don't see enough benefit at this point.
Since the width and length axis are equivalent to one another, if I zoom in on the right hand plot the aspect ratio should be preserved. As a result both plots should zoom in together and mirror one another. That is not the case currently.
This can be repeated by drawing a rectangle zoom on the contour plot within the second subplot on the right. Observe that aspect ratio is lost, and that the first subplot on the left mirrors the action in a nonsense manner.
Any deviation from the width and length parameters not being equal provides a misleading representation in this geometric case.
Is there any update on this? The milestone is definitely not up to date.
We've encountered this issue trying to plot honeycomb lattice over here. Funnily 3D plotting has equal aspect ratios automatically (for no obvious reason).
Just for those who find this deserted place via google, I found that manually setting the plot aspect ratio through height and width is an acceptable (although fragile) workaround.
Reacted by Matthew Wilkins, PhD, Ricardo Decal, Trevor Tanner and Steffen Elting
Is there any news on this issue?
I would also greatly appreciate something like "equal_axes=True", "axes('equal')" or "set_aspectratio=1" in a 2D plot with plotly.
Has it been implemented? If yes, what exactly is the syntax?
Reacted by Adam Plowman, Fabien Pfaender, Pablo M. Reyes, Hyper Power, Noelia Oses Fernandez, Susann Bader, sme, Matthew Wilkins, PhD, Jason K. Moore, Jakub Stępak and 22 more
Reacted by Edward Leonard and Hyper Power
Reacted by Haojun Jiang, Chenyu Zhang, Sandra and Ahmad Pesaranghader
Part of this issue is solved in the latest version of plotly.js via this "Axis Constraints" PR - plotly/plotly.js#1522 - which enables optional fixed aspect ratio on zoom.
The other feature brought up in this issue (coordinated zoom on subplots sharing an axis) would also need to be solved in plotly.js. Issue here: plotly/plotly.js#1549
The fig['layout'].update(width=500, height=500, autosize=False) trick is not working as expected for me, so I will have to manually set the aspect ratio of each axis (x, y, z) or do some other thing. It would be great to have this in plotly!
@Juanlu001 thanks for the layout trick. Any idea how to change the scale of the Z axis (without multiplying)? Basically X/Y axis are on same pixel scale and Z is on another scale.
This gives me X & Y axis on the same pixel scale and then I can tune the Z scale by a multiple while keeping the ticks on the X,Y,Z axis in the correct data scale.
Reacted by KODeKarnage, AstronoTech and Roly Perera
Activity
theengineear commentedon Jul 15, 2014
@chriddyp, thoughts? This is a common one, especially for heatmaps/contour plots. Here are a couple of ways we might implement this:
FigureorLayout?)fig['layout'].update(width=500, height=500, autosize=False)py.plot(fig, equal_axes=True)I'd probably lean towards better documenting (2), but would consider (3). In addition, it would probably be a good idea to write in some logic that sets
auto*=Falsewhenever the appropriate keys are properly filled in, e.g., bothwidthandheight.@arsenovic, it seems like you were maybe thinking of (1), do either (2) or (3) work for you?
etpinard commentedon Jul 15, 2014
What about making
'autosize'support True, False, and 'equal-axis' values?(which would require modifications on our backend)
arsenovic commentedon Jul 15, 2014
it may be too greedy, but ideally you can have the graph auto-sizeable, but retain squareness. so whenever one width or height changes the other does too.
of the above options (3) is nice. (2) is a no so good, because the concepts of aspect ratio and size should be independent.
theengineear commentedon Jul 15, 2014
I see, yeah. It would be annoying for a user to have to decide before hand how big they want the final image...
@alexcjohnson, is there currently a way to let Plotly pick the size, but retain the aspect ratio?
I could imagine it would be useful for users to set something like:
{ "layout": { "height": 1, "width": 2, "dimension": "ratio", "autosize": false } }Where
dimensioncould have "ratio", "pixels". We'd keep "autosize" to mean absolutely let Plotly chose the dimensions, i.e., you wouldn't get the requested aspect ratio unless"autosize": false.alexcjohnson commentedon Jul 15, 2014
Interesting, we can't do this now but it could definitely be a useful feature. Also seeing @arsenovic on here (howdy!) reminds me we'll need something similar for axes, if you want to enforce a particular aspect ratio as you zoom around - like for smith charts and maps.
The other thing I've been pondering re: autosize is some sort of responsive mode, where the fonts, margins, line widths, marker sizes... get adjusted as the size changes. Maybe linearly, (in the minimum dimension?) maybe something more sophisticated. Would be useful for publishers who want a responsive layout (they'll have to resize their iframe in javascript but then we can redraw the plot appropriately). Thoughts?
dab3-2014 commentedon Jan 16, 2015
Hi...I would like to help implementing solution # 3 in 2nd post, this one:
3.throw it in the plot call, py.plot(fig, equal_axes=True)
So would it be possible if some one more familiar with the code let us know a good point to start to implement this option in the plot function? It would be great if you point us in the right direction.
chriddyp commentedon Jan 19, 2015
@dab3-2014 - I think we're going to stay away from #3 but instead for people to set
widthandheightinlayout. My thought is that setting the size and the aspect ratio is setting the same number of things as setting the width and the height, so I don't see enough benefit at this point.SimonBiggs commentedon Jan 20, 2015
@chriddyp - An example of where axis equal would be a huge benefit is in what I am using plotly for right now:
https://plot.ly/~SimonBiggs/113/bivariate-quadratic-spline-fit-using-the-parameters-equivalent-width-and-equival/
Since the width and length axis are equivalent to one another, if I zoom in on the right hand plot the aspect ratio should be preserved. As a result both plots should zoom in together and mirror one another. That is not the case currently.
This can be repeated by drawing a rectangle zoom on the contour plot within the second subplot on the right. Observe that aspect ratio is lost, and that the first subplot on the left mirrors the action in a nonsense manner.
Any deviation from the width and length parameters not being equal provides a misleading representation in this geometric case.
akhmerov commentedon Feb 4, 2016
Is there any update on this? The milestone is definitely not up to date.
We've encountered this issue trying to plot honeycomb lattice over here. Funnily 3D plotting has equal aspect ratios automatically (for no obvious reason).
l-astro commentedon Mar 7, 2016
echoing @akhmerov 's comment - is there any update on this?
akhmerov commentedon Mar 7, 2016
Just for those who find this deserted place via google, I found that manually setting the plot aspect ratio through height and width is an acceptable (although fragile) workaround.
l-astro commentedon Mar 8, 2016
A square plot area is seems difficult to achieve (perhaps I'm missing something) with a colorbar visible.
priisdk commentedon Jan 29, 2017
Is there any news on this issue?
I would also greatly appreciate something like "equal_axes=True", "axes('equal')" or "set_aspectratio=1" in a 2D plot with plotly.
Has it been implemented? If yes, what exactly is the syntax?
tachim commentedon Mar 21, 2017
+1, this screws up any attempt at visualizing things like surface normals in 3D point clouds
tachim commentedon Mar 21, 2017
@akhmerov can you elaborate on your solution?
akhmerov commentedon Mar 21, 2017
@tachim I don't remember anymore, it's been a while. Everything we've done is in https://github.com/adriaanvuik/solid_state_physics
jackparmer commentedon Apr 5, 2017
Part of this issue is solved in the latest version of plotly.js via this "Axis Constraints" PR - plotly/plotly.js#1522 - which enables optional fixed aspect ratio on zoom.
The other feature brought up in this issue (coordinated zoom on subplots sharing an axis) would also need to be solved in plotly.js. Issue here: plotly/plotly.js#1549
Any companies interested in sponsoring this?
https://plot.ly/products/consulting-and-oem/
priisdk commentedon Apr 17, 2017
Can someone please give a simple example of a scatter plot with fixed ratio on zoom?
bcdunbar commentedon May 26, 2017
Example of fixed ratio here https://plot.ly/python/axes/#fixed-ratio-axes and reference info here https://plot.ly/python/reference/#layout-xaxis-scaleanchor
astrojuanlu commentedon Oct 31, 2017
The
fig['layout'].update(width=500, height=500, autosize=False)trick is not working as expected for me, so I will have to manually set the aspect ratio of each axis (x, y, z) or do some other thing. It would be great to have this in plotly!astrojuanlu commentedon Oct 31, 2017
...although
fig['layout'].update(scene=dict(aspectmode="data"))did the trick!dragoljub commentedon Feb 7, 2019
@Juanlu001 thanks for the layout trick. Any idea how to change the scale of the Z axis (without multiplying)? Basically X/Y axis are on same pixel scale and Z is on another scale.
astrojuanlu commentedon Feb 8, 2019
@dragoljub you're welcome! does plotly/documentation#1182 answer your question?
dragoljub commentedon Feb 8, 2019
I ended up using this to get it working to my needs:
This gives me X & Y axis on the same pixel scale and then I can tune the Z scale by a multiple while keeping the ticks on the X,Y,Z axis in the correct data scale.