question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Aspect on semi-log plots

See original GitHub issue

The aspect parameter can be used to set the aspect of a plot:

%%opts Curve [ aspect=2]
hv.Curve((np.linspace(0.1,10 )))

download

However, when setting one of the axis to log, the aspect parameter is ignored:

%%opts Curve [logy=True, aspect=2]
hv.Curve((np.linspace(0.1,10 ),np.linspace(0.1,100 )))

download 1

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
NGilletcommented, Nov 15, 2018

A temporary solution is to set the figure size to force it to be square:

fig, ax = plt.subplots(  )
ax.set_yscale("log", nonposy='clip')
...
fig_size = fig.get_size_inches()
fig.set_size_inches( fig_size[1]*1.1, fig_size[1]*1.1 )

the 1.1 scaling is for avoiding cuts in the labels, should be adapted for case to case.

0reactions
jadolfbrcommented, Sep 26, 2019

@philippjfr - You say you have a fix for loglog plots, but I still cannot get an equal aspect ratio for them. Anytime I attempt to set it - it squishes the X axis while elongating the y axis. Otherwise, its pretty much the opposite.

plt.scatter(n_data[x_group], n_data[y_group], marker='D', s=23) 

axes = plt.gca()
axes.set_xlim([min_x,max_x])
axes.set_ylim([min_y,max_y])

plt.plot([min_x, max_x], [min_y, max_y], 'k-')
plt.loglog()
plt.gca().set_aspect('equal', adjustable='box')

Results in something like this:

image

Am I doing something inherently wrong with trying to get an equal aspect ratio? Is there any workaround? I’ve also tried setting the xscale and yscale to logs, same thing.

Similar code, but for non log/log gives something like this: image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Aspect ratio in semi-log plot with Matplotlib - Stack Overflow
I want the ratio of the length and height of this rectangle to be given by the golden mean ,i.e., dx/dy=1.618033... If the...
Read more >
Aspect on semi-log plots · Issue #996 · holoviz/holoviews
I've noticed this as well and haven't yet been able to figure out what's going on here. Presumeably this expression doesn't work correctly ......
Read more >
Semilog plot (x-axis has log scale) - MATLAB semilogx
This MATLAB function plots x- and y-coordinates using a base-10 logarithmic scale on the x-axis and a linear scale on the y-axis.
Read more >
Semi-Log Plot - an overview | ScienceDirect Topics
Special note: the concentration of drug in plasma is commonly plotted on a semi-log plot, ie, the x-axis is linear and y-axis is...
Read more >
Semi-log plot - Wikipedia
The log–linear type of a semi-log graph, defined by a logarithmic scale on the y-axis (vertical), and a linear scale on the x-axis...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found