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.

Improve tight layout algorithm handling of empty gridspec slots

See original GitHub issue

Description

When some subplots have colorbar and some don’t, the position will be wrong.

Steps to reproduce

import proplot as pplt
import numpy as np

# Colorbars
fig, axs = pplt.subplots(nrows=2, ncols=2)
state = np.random.RandomState(51423)

m = axs.heatmap(state.rand(10, 10), cmap='dusk')
axs[0].colorbar(m[0], loc='r', label='test')
axs[1].colorbar(m[0], loc='r', label='test')
axs[3].colorbar(m[0], loc='l', label='test')
axs[3].colorbar(m[0], loc='r', label='test')
axs[3].colorbar(m[0], loc='r', label='test')

Actual behavior:

image

Proplot version

Paste the results of import matplotlib; print(matplotlib.__version__); import proplot; print(proplot.version)here.

3.5.0
0.9.5.post105

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
lukelbdcommented, Jan 24, 2022

Done! Here’s how this looks now:

import proplot as pplt
import numpy as np
fig, axs = pplt.subplots(nrows=2, ncols=2)
state = np.random.RandomState(51423)
m = axs.heatmap(state.rand(10, 10), cmap='dusk')
axs[0].colorbar(m[0], loc='r', label='test')
axs[3].colorbar(m[0], loc='l', label='test')

test

0reactions
zxdawncommented, Jan 24, 2022

Nice idea of equalspace and groupspace!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Improve tight layout algorithm handling of empty gridspec slots
The solution is: If a gridspec slot is empty, instead of just skipping the tight layout test, I should jump to the next...
Read more >
proplot.gridspec — ProPlot documentation
If :rcraw:`subplots.tight` is ``True``, the space is determined by the tight layout algorithm. Otherwise, a sensible default value is chosen.
Read more >
CSS Grid Layout Module Level 1 - W3C
This CSS module defines a two-dimensional grid-based layout system, ... arbitrary slots in a predefined flexible or fixed-size layout grid.
Read more >
Exercise: Working with External Libraries Daily - Kaggle
Explore and run machine learning code with Kaggle Notebooks | Using data from No attached data sources.
Read more >
Figure subfigures — Matplotlib 3.6.2 documentation
Sometimes it is desirable to have a figure with two different layouts in it. ... in the empty gridspec slots: subfig = fig.add_subfigure(gridspec[:, ......
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