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: make example cursor show up in the docs #1506

Closed
wants to merge 1 commit into from

Conversation

ivanov
Copy link
Member

@ivanov ivanov commented Nov 16, 2012

As can be seen over in our gallery, the cursor widget does not get displayed in the generated image, since documentation images get generated without a GUI backend.

I've modified that example so that the image the gets generated actually will have a red cursor, by "injecting" a fake GUI event.

This is a documentation only update, but wanted to get feedback if people think this is ok. I just think that visually, it makes it much easier to find this example or see what it might be doing with my proposed change.

edit hang on, I'm not sure this actually works for the generated examples...

@ivanov
Copy link
Member Author

ivanov commented Nov 16, 2012

hmm, it seems that the cursor does not get saved along with the image (this is likely a feature and not a bug).

I've updated this PR to just manually add axhline and axvline and added a note about them in the comments

Here's what the original patch looked like: ivanov/matplotlib@4449e9d, but for the life of me, I could not figure it how to insert the lines from the cursor into the plot and get them to get saved.

@pelson
Copy link
Member

pelson commented Nov 16, 2012

I'm not sure I'm in favour of this. The gallery isn't the only reason we have examples. For me, the benefit of being able to run the code to produce the same plot is fantastic. The problem with this change is that if I run the code, I get a strange looking cross on my plot...

Personally, I wouldn't even be in favour of adding some conditionals in there to only add a simulated cursor if generating the docs (it muddies the example).

Out of interest, there seems to be an example in the gallery (http://matplotlib.org/plot_directive/mpl_examples/widgets/thumbnails/cursor.png), but when I actually go to the example, there is no rendered image: http://matplotlib.org/examples/widgets/cursor.html . Did I miss something?

Cheers,

@ivanov
Copy link
Member Author

ivanov commented Nov 16, 2012

What this turned into is indeed not so clean. I wish I could get something like ivanov/matplotlib@4449e9d to save to a png as it looks, because there, once you mouse the mouse, the cursor moves with it. Any thoughts there?

Out of interest, there seems to be an example in the gallery (http://matplotlib.org/plot_directive/mpl_examples/widgets/thumbnails/cursor.png), but when I actually go to the example, there is no rendered image: http://matplotlib.org/examples/widgets/cursor.html . Did I miss something?

Yeah, I was focusing on the thumbnail, but actually see that same behavior locally for cursor.html. Looking at the generated .rst files, all of the ones for the widgets and misc directories end up having:

[`source code <cursor.py>`_]

whereas the ones that do generate an image have something like this instead

.. plot:: /home/pi/code/matplotlib/doc/mpl_examples/pylab_examples/accented_text.py

I can't seem to track down right now where that decision is coming from, though.

@WeatherGod
Copy link
Member

On Friday, November 16, 2012, Paul Ivanov wrote:

What this turned into is indeed not so clean. I wish I could get something
like ivanov/matplotlib@4449e9dhttps://github.com/ivanov/matplotlib/commit/4449e9dto save to a png as it looks, because there, once you mouse the mouse, the
cursor moves with it. Any thoughts there?

Out of interest, there seems to be an example in the gallery (
http://matplotlib.org/plot_directive/mpl_examples/widgets/thumbnails/cursor.png),
but when I actually go to the example, there is no rendered image:
http://matplotlib.org/examples/widgets/cursor.html . Did I miss something?

Yeah, I was focusing on the thumbnail, but actually see that same behavior
locally for cursor.html. Looking at the generated .rst files, all of the
ones for the widgets and misc directories end up having:

[source code <cursor.py>_]

whereas the ones that do generate an image have something like this instead

.. plot:: /home/pi/code/matplotlib/doc/mpl_examples/pylab_examples/accented_text.py

I can't seem to track down right now where that decision is coming from,
though.

IIRC, there are some hard coded directories such as animation that are
skipped. It is in gen_gallary.py oor something like that.

@ivanov ivanov closed this Dec 8, 2012
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.

None yet

3 participants