Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

adding from_list to custom cmap tutorial #6662

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

Merged
merged 1 commit into from
Jun 29, 2016

Conversation

choldgraf
Copy link
Contributor

This PR adds a bit more explanation to the docstring for this tutorial, rearranges the data creation to be at the beginning, and adds a small section that shows how to create a colormap from a list of RGB tuples.

@NelleV WDYT?

@choldgraf
Copy link
Contributor Author

Ah, and it creates this extra figure, illustrating the N parameter for from_list: figure_1

@choldgraf
Copy link
Contributor Author

btw, let me know if you want me to change the other objects in this tutorial so they're object-based instead of plt. based. I think somebody mentioned they'd like to see that but don't know if it's worth it or not.

colors = [(1, 0, 0), (0, 1, 0), (0, 0, 1)] # R -> G -> B
n_bins = [2, 5, 10, 100] # Discretizes the interpolation into bins
cmap_name = 'my_list'
f, axs = plt.subplots(1, 4, figsize=(10, 5))
Copy link
Member

Choose a reason for hiding this comment

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

I think the convention is as follow:

fig, axes = plt.subplots()

Maybe @mdboom or @tacaswell can confirm?
In any case, we should be as consistent as possible on the whole file. There are other places in this example that don't use the object oriented interface: do you mind editing those as well (for example l.170 to 182).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool - yep I can edit those as well (see my latest comment on the main thread).

Copy link
Member

Choose a reason for hiding this comment

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

Great! Thanks.

Copy link
Contributor Author

@choldgraf choldgraf Jun 28, 2016

Choose a reason for hiding this comment

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

It looks like the colorbar mapping is somewhat different when doing it object-oriented style. If I do im = imshow(... and then call fig.colorbar(im, cax=ax[0, 0]), etc, then it gives a plot like this:

image

I think the colorbars are super tiny in the corners. Know how I can fix this?

Copy link
Member

Choose a reason for hiding this comment

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

The cax kwarg takes an Axes that you have made yourself to hold the colorbar; I think what you want is the ax kwarg, which takes the parent Axes from which space for the colorbar will be taken.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hooray that worked!

On Tue, Jun 28, 2016 at 10:27 AM, Eric Firing notifications@github.com
wrote:

In examples/pylab_examples/custom_cmap.py
#6662 (comment):

+colors = [(1, 0, 0), (0, 1, 0), (0, 0, 1)] # R -> G -> B
+n_bins = [2, 5, 10, 100] # Discretizes the interpolation into bins
+cmap_name = 'my_list'
+f, axs = plt.subplots(1, 4, figsize=(10, 5))

The cax kwarg takes an Axes that you have made yourself to hold the
colorbar; I think what you want is the ax kwarg, which takes the parent
Axes from which space for the colorbar will be taken.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/matplotlib/matplotlib/pull/6662/files/b380fd7bae75b8dc9d12d24977f177175674f317#r68802996,
or mute the thread
https://github.com/notifications/unsubscribe/ABwSHWIznsZA2Ju7IYpNa1D0U5yXuIR4ks5qQVl6gaJpZM4JAULd
.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(thx)

On Tue, Jun 28, 2016 at 10:29 AM, Chris Holdgraf choldgraf@gmail.com
wrote:

hooray that worked!

On Tue, Jun 28, 2016 at 10:27 AM, Eric Firing notifications@github.com
wrote:

In examples/pylab_examples/custom_cmap.py
#6662 (comment)
:

+colors = [(1, 0, 0), (0, 1, 0), (0, 0, 1)] # R -> G -> B
+n_bins = [2, 5, 10, 100] # Discretizes the interpolation into bins
+cmap_name = 'my_list'
+f, axs = plt.subplots(1, 4, figsize=(10, 5))

The cax kwarg takes an Axes that you have made yourself to hold the
colorbar; I think what you want is the ax kwarg, which takes the parent
Axes from which space for the colorbar will be taken.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/matplotlib/matplotlib/pull/6662/files/b380fd7bae75b8dc9d12d24977f177175674f317#r68802996,
or mute the thread
https://github.com/notifications/unsubscribe/ABwSHWIznsZA2Ju7IYpNa1D0U5yXuIR4ks5qQVl6gaJpZM4JAULd
.

@NelleV
Copy link
Member

NelleV commented Jun 28, 2016

Hi Chris,

Thanks for the patch! I think the additional documentation is great.
Have you tried building the sphinx documentation? If so, do you mind adding an image of how this example page looks on the pull request?

Thanks,
Nelle

@choldgraf
Copy link
Contributor Author

I'll try building sphinx after updating the commit. Can you give a quick reminder on how to do this, it's been a while since I've built docs

@choldgraf choldgraf force-pushed the tutorial_fromlist_cmap branch from b380fd7 to 963ded8 Compare June 28, 2016 17:34
@choldgraf
Copy link
Contributor Author

Actually it's just python ./doc/make.py html isn't it? I'm getting a weird error about latex_math already being registered. Do you know if there's a way to throw warnings for something like that instead of erroring?

@efiring
Copy link
Member

efiring commented Jun 28, 2016

Use the --allowsphinxwarnings option to make.py.

@NelleV
Copy link
Member

NelleV commented Jun 28, 2016

@efiring this is IMO a bit annoying. If we used the "newer" build system of sphinx, that would not happen. I can easily create a PR with the new Makefile (and make.bat) files. Would that be of any interest to the project?

@jenshnielsen
Copy link
Member

That warning is caused by Sphinx 1.4x being stricter And already fixed on current master. The easiest way to suppress it rather than allowing it is to either rebase on current master or downgrade Sphinx to 1.3x

@jenshnielsen
Copy link
Member

@NelleV Setting warningsaserrors as the default is done very much on purpose and as the person that fixed more than 800 Sphinx warnings before that became possible I would be very hard to convince to change this. Travis builds the docs every a branch is pushed with warnings as errors and it works just fine

@jenshnielsen
Copy link
Member

This is the PR that fixes it #6238 which was merged a few days after Sphinx 1.4 was released

@NelleV
Copy link
Member

NelleV commented Jun 28, 2016

@jenshnielsen I'm running the latest matplotlib, and I still have this problem while using make.py.

@jenshnielsen
Copy link
Member

Sorry I misunderstood I thought you wanted to change to Makefiles to get rid of the warningsaserrors

It's puzzling that you still see this error since travis builds without that warning and has done for a long time

@NelleV
Copy link
Member

NelleV commented Jun 28, 2016

In any case, the make.py file is antiquated. The new version of the matplotlib build would not have required the patch from #6238 . The problem with make.py is that it does not guet updated with the library, but it should. Hence the move from generating the make.py to a makefile that calls itself the sphinx-build executable.

@jenshnielsen
Copy link
Member

Im happy to convert to Makefiles as long as we build the docs with warningsaserrors

@choldgraf
Copy link
Contributor Author

ah thanks for that - sphinx is building now w/ the flag...gonna take a bit of time for it to finish, I'll update when that's done

@NelleV
Copy link
Member

NelleV commented Jun 28, 2016

@jenshnielsen I don't think it makes sense to activate the -W option if we have to disable it to have the documentation build… It is what is happening right now. It doesn't bring any advantages, and has the strong disaventages of increasing the difficulty of building the documentation, and thus of contributing to matplotlib.

@jenshnielsen
Copy link
Member

It at the very least need to be the enabled on Travis as I said I had to fix more than 800 warnings including very significant wrongly rendered pages that went unnoticed for years. Since we made this the default on travis we have caught a large number of pr's with invalid RST syntax which would have been unnoticed and only fixed years later. We can change the default and make this optional again i.e. revert 1af4ca0

@choldgraf
Copy link
Contributor Author

Here's how it looks in the docs:
image

@NelleV
Copy link
Member

NelleV commented Jun 29, 2016

That looks good to me. I don't really understand why the appveyor build fails, and I don't think it has anything to do with your PR.

Thanks for the patch!

@choldgraf
Copy link
Contributor Author

Yeah I couldn't figure that one out either...but didn't seem related. Let
me know if there's anything else you'd like me to do!

Chris

On Tue, Jun 28, 2016 at 10:55 PM, Nelle Varoquaux notifications@github.com
wrote:

That looks good to me. I don't really understand why the appveyor build
fails, and I don't think it has anything to do with your PR.

Thanks for the patch!


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#6662 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/ABwSHQ6SQaefFHZNYW4pO4noIuo8xyqAks5qQgi7gaJpZM4JAULd
.

@NelleV NelleV changed the title adding from_list to custom cmap tutorial [MRG+1] adding from_list to custom cmap tutorial Jun 29, 2016
@jenshnielsen
Copy link
Member

appveyor have some issues at the moment #6520 is work towards resolving it

@tacaswell tacaswell merged commit 5151cf5 into matplotlib:master Jun 29, 2016
tacaswell added a commit that referenced this pull request Jun 29, 2016
DOC: adding from_list to custom cmap tutorial
@tacaswell
Copy link
Member

Thanks!

backported to v1.5.x as 9e5b18a

@choldgraf
Copy link
Contributor Author

🎉 🎉 🎉

@QuLogic QuLogic added this to the 1.5.2 (Critical bug fix release) milestone Jun 29, 2016
@QuLogic QuLogic changed the title [MRG+1] adding from_list to custom cmap tutorial adding from_list to custom cmap tutorial Oct 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.