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.

Achieving square aspect for Facetgrid heatmaps

See original GitHub issue
import xarray as xr
import numpy as np
%matplotlib inline

array = xr.DataArray(np.random.rand(20,5,2,1), dims=['a', 'b', 'c', 'd'])
array.plot(x='a', y='b', col='c')

image

Problem description

How can I force these heatmap cells into squares rather than rectangles? I’m aware that it is possible to pass kwargs through to Seaborn’s FacetGrid, but setting square=True or subplot_kws={'square":True} both raise AttributeError: Unknown property square.

INSTALLED VERSIONS ------------------ commit: None python: 3.6.6.final.0 python-bits: 64 OS: Darwin OS-release: 16.7.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: en_GB.UTF-8 LOCALE: en_GB.UTF-8

xarray: 0.10.8 pandas: 0.23.4 numpy: 1.15.1 scipy: 1.1.0 netCDF4: None h5netcdf: None h5py: None Nio: None zarr: None bottleneck: 1.2.1 cyordereddict: None dask: 0.18.2 distributed: 1.22.1 matplotlib: 2.2.3 cartopy: None seaborn: 0.9.0 setuptools: 40.2.0 pip: 10.0.1 conda: 4.5.11 pytest: 3.7.3 IPython: 6.5.0 sphinx: 1.7.7

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jbuseckecommented, Sep 21, 2018

I would prefer axis_aspect to allow other than square aspects.

1reaction
dcheriancommented, Sep 7, 2018
g = array.plot(x='a', y='b', col='c')
[axis.set_aspect('equal') for axis in g.axes.ravel()]

image

Is this what you want?

I don’t know that we need to add square=True as a supported argument but consistency with seaborn could be a good thing I guess. Thoughts?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make heatmap square in Seaborn FacetGrid
To adjust quadratic heatmap and axis you may set corrected axis bounding box position manually with function set_bbox . Another way is a...
Read more >
How to make a heatmap square in Seaborn FacetGrid using ...
To make a heatmap square in Seaborn facetgrid, we cn use heatmap() method with 10×10 random data set. Steps. Create a random data...
Read more >
Making Faceted Heatmaps with ggplot2 | rud.is
This ensures the plot will have a 1:1 aspect ratio (i.e. geom_tile() –which draws rectangles–will draw nice squares). gg <- gg + coord_equal()....
Read more >
Intermediate Data Visualization with ggplot2 - AWS
Quantile regression is a great tool for getting a more detailed overview of a large ... Using a 1:1 aspect ratio would make...
Read more >
seaborn heatmap legend - You.com | The search engine you control.
Getting a legend in a seaborn FacetGrid heatmap plot ... Draw the heatmap with the mask and correct aspect ratio _ = sns.heatmap(df,...
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