proplot-dev / proplot

🎨 A succinct matplotlib wrapper for making beautiful, publication-quality graphics
https://proplot.readthedocs.io
MIT License
1.12k stars 102 forks source link

bug: cannot set equal aspect for log scale #425

Closed kinyatoride closed 1 year ago

kinyatoride commented 1 year ago

Steps to reproduce

import proplot as pplt

fig, ax = pplt.subplots()
ax.format(
    aspect='equal', 
    xscale='log', yscale='log',
)

Actual behavior: [What actually happened]

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
File [~/.conda/envs/pplt/lib/python3.10/site-packages/IPython/core/formatters.py:340], in BaseFormatter.__call__(self, obj)
    338     pass
    339 else:
--> 340     return printer(obj)
    341 # Finally look for special method names
    342 method = get_real_method(obj, self.print_method)

File [~/.conda/envs/pplt/lib/python3.10/site-packages/IPython/core/pylabtools.py:169], in retina_figure(fig, base64, **kwargs)
    160 def retina_figure(fig, base64=False, **kwargs):
    161     """format a figure as a pixel-doubled (retina) PNG
    162 
    163     If `base64` is True, return base64-encoded str instead of raw bytes
   (...)
    167         base64 argument
    168     """
--> 169     pngdata = print_figure(fig, fmt="retina", base64=False, **kwargs)
    170     # Make sure that retina_figure acts just like print_figure and returns
    171     # None when the figure is empty.
    172     if pngdata is None:

File [~/.conda/envs/pplt/lib/python3.10/site-packages/IPython/core/pylabtools.py:152], in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File [~/.conda/envs/pplt/lib/python3.10/site-packages/proplot/figure.py:468], in _add_canvas_preprocessor.._canvas_preprocess(self, *args, **kwargs)
    466 ctx3 = rc.context(fig._mathtext_context)  # draw with figure-specific setting
    467 with ctx1, ctx2, ctx3:
--> 468     fig.auto_layout()
    469     return func(self, *args, **kwargs)

File [~/.conda/envs/pplt/lib/python3.10/site-packages/proplot/figure.py:1431], in Figure.auto_layout(self, renderer, aspect, tight, resize)
   1429     return
   1430 if aspect:
-> 1431     gs._auto_layout_aspect()
   1432 _align_content()
   1433 if tight:

File [~/.conda/envs/pplt/lib/python3.10/site-packages/proplot/gridspec.py:843], in GridSpec._auto_layout_aspect(self)
    841     aspect = ratio [/](https://vscode-remote+ssh-002dremote-002bgpu1.vscode-resource.vscode-cdn.net/) ax.get_data_ratio()
    842 elif xscale == 'log' and yscale == 'log':
--> 843     aspect = ratio [/](https://vscode-remote+ssh-002dremote-002bgpu1.vscode-resource.vscode-cdn.net/) ax.get_data_ratio_log()
    844 else:
    845     return  # matplotlib should have issued warning

AttributeError: 'CartesianAxesSubplot' object has no attribute 'get_data_ratio_log'

Equivalent steps in matplotlib

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.set_aspect('equal')
ax.set_xscale('log')
ax.set_yscale('log')

output

Proplot version

3.4.3 0.9.7

lukelbd commented 1 year ago

This was fixed on master by 7cda3b23958f6f5896070b485d3db7210b3faec9, was due to another matplotlib dependency issue.