Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: Plot discrete colormap with proportional colorbar #1930

Merged
merged 7 commits into from
Feb 27, 2018

Conversation

paulvija
Copy link
Contributor

@paulvija paulvija commented Feb 21, 2018

Using 'cbar_kwargs' it is possible to extend the capabilities of colorbar ticks.

paulvija and others added 2 commits February 21, 2018 15:29
Using 'cbar_kwargs' it is possible to extend the capabilities of colorbar ticks.
Proportional colorbar for discrete colormaps
=================================

While plotting a discrete colormap you may wish to label every colorbar ticks. By default, the tick labels are limited to a number of 10.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501 line too long (137 > 79 characters)

=================================

While plotting a discrete colormap you may wish to label every colorbar ticks. By default, the tick labels are limited to a number of 10.
However, you can use the ``cbar_kwargs`` keyword to specify the number of ticks. It is also possible to arrange the spacing between ticks if ``levels`` are not regular.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E501 line too long (168 > 79 characters)

f, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(14, 4))

# Different levels
levels = [200,210,220,230,240,250,260,270,280,290,320]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E231 missing whitespace after ','


"""

import xarray as xr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W1618 import missing from __future__ import absolute_import

@shoyer
Copy link
Member

shoyer commented Feb 22, 2018

Apparently we did not successfully disable stickler in doc directories.

But please do fix the line-length issue. I don't think using an absolute import would improve clarity here.

@shoyer shoyer mentioned this pull request Feb 22, 2018
Shortened intro texts.
``spacing`` can be used to draw the ticks proportional too.
"""

import xarray as xr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W1618 import missing from __future__ import absolute_import

added absolute_import to make stickler happy, can be removed later.
Copy link
Member

@fmaussion fmaussion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! A few small changes and this should be good to go.

# -*- coding: utf-8 -*-
"""
============================================
Proportional colorbar for discrete colormaps
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe: Control the plot's colorbar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes more sense.

============================================

Use ``cbar_kwargs`` keyword to specify the number of ticks.
``spacing`` can be used to draw the ticks proportional too.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... to draw proportional ticks.

Use ``cbar_kwargs`` keyword to specify the number of ticks.
``spacing`` can be used to draw the ticks proportional too.
"""
from __future__ import absolute_import
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, please ignore our bot on this one: remove this line

Copy link
Member

@shoyer shoyer Feb 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bot has been terminated -- if you merge in master, it should no longer bother you!

# Load the data
air_temp = xr.tutorial.load_dataset('air_temperature')
air = air_temp.air
air2d = air.isel(time=500)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge in one line:

air2d = air_temp.air.isel(time=500)

Renamed the script, script info updated.
Use ``cbar_kwargs`` keyword to specify the number of ticks.
``spacing`` can be used to draw proportional ticks..
"""
import xarray as xr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W1618 import missing from __future__ import absolute_import

@paulvija
Copy link
Contributor Author

@shoyer Looks like stickler bot is still active.

@fmaussion fmaussion changed the title Plot discrete colormap with proportional colorbar DOC: Plot discrete colormap with proportional colorbar Feb 27, 2018
Use ``cbar_kwargs`` keyword to specify the number of ticks.
The ``spacing`` kwarg can be used to draw proportional ticks.
"""
import xarray as xr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W1618 import missing from __future__ import absolute_import

@fmaussion fmaussion merged commit ecf50d2 into pydata:master Feb 27, 2018
@fmaussion
Copy link
Member

Thanks @paulvija !

shoyer pushed a commit that referenced this pull request Feb 28, 2018
* Plot discrete colormap with proportional colorbar

Using 'cbar_kwargs' it is possible to extend the capabilities of colorbar ticks.

* Fixing style errors.

* Fixing style errors.

* Fixed the line-length issue

Shortened intro texts.

* added absolute_import

added absolute_import to make stickler happy, can be removed later.

* Updated script with changes requested

Renamed the script, script info updated.

* Cosmetic changes
@paulvija
Copy link
Contributor Author

@fmaussion Would the plot image display automatically here or something I have to do at my end?
http://xarray.pydata.org/en/latest/auto_gallery/control_plot_colorbar.html

@shoyer
Copy link
Member

shoyer commented Mar 1, 2018

Hmm, I'm not sure. Let's see if rebuilding the docs fixes it...

If that doesn't work, it might be a good idea to do some tests with a local docs build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants