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

Incorrect example for interactive plotting in Matplotlib Usage FAQ #8883

Closed
vab9 opened this issue Jul 15, 2017 · 4 comments

Comments

Projects
None yet
5 participants
@vab9
Copy link
Contributor

commented Jul 15, 2017

Bug report

Bug summary

The interactive example in the Matplotlib FAQ does not work as described.

Code for reproduction

I followed these very simple instructions from the FAQ:

# in shell execute one by one:
import matplotlib.pyplot as plt

plt.ion()
plt.plot([1.6, 2.7])

# plot is shown

plt.title("interactive test")
plt.xlabel("index")

# plot is updated with titel and label

ax = plt.gca()
ax.plot([3.1, 2.2])

# (!) second line is added to the axes
# no need to call:
# plt.draw()

When I execute:

# Paste your code here
ax = plt.gca()
ax.plot([3.1, 2.2])

my plot immediately updates with the new line. The FAQ claims this should not happen until I call draw().

The same thing happens when I use the 'TKAgg' backend and not my default 'MacOSX'. I also tried this with both Python and iPython.

Actual outcome

Plot is updated with new line.

Expected outcome

Plot should not be updated until draw() is called.

Matplotlib version

  • Operating System: Mac OSX 10.11.6
  • Matplotlib Version: 2.0.2
  • Python Version: 3.6.1
  • Anaconda Version: 4.4.0
  • Jupyter Version (if applicable): 4.3.0

Installed matplotlib by installing Anaconda 4.4.0 (default channel).

@WeatherGod

This comment has been minimized.

Copy link
Member

commented Jul 15, 2017

@vab9

This comment has been minimized.

Copy link
Contributor Author

commented Jul 15, 2017

Thanks for the quick reply! So is the FAQ wrong where it says:

Axes methods do not include an automatic call to draw_if_interactive(); that call is added by the pyplot functions.

? Or am I misunderstanding that sentence somehow? Do you know if this behaviour is consistent across other interactive backends?

Thanks for clarifying this for me. If you let me know where we can edit the FAQ, I'd be glad to open a PR...

@WeatherGod

This comment has been minimized.

Copy link
Member

commented Jul 15, 2017

vab9 added a commit to vab9/matplotlib that referenced this issue Jul 16, 2017

Update Usage FAQ to reflect new behaviour
The [interactive example](https://matplotlib.org/faq/usage_faq.html#interactive-example) in the Usage FAQ was outdated. The change reflects new behaviour since version 1.5. See Issue matplotlib#8883 for more details.

dstansby added a commit to vab9/matplotlib that referenced this issue Jul 29, 2017

Update Usage FAQ to reflect new behaviour
The [interactive example](https://matplotlib.org/faq/usage_faq.html#interactive-example) in the Usage FAQ was outdated. The change reflects new behaviour since version 1.5. See Issue matplotlib#8883 for more details.

tacaswell added a commit to vab9/matplotlib that referenced this issue Aug 6, 2017

Update Usage FAQ to reflect new behaviour
The [interactive example](https://matplotlib.org/faq/usage_faq.html#interactive-example) in the Usage FAQ was outdated. The change reflects new behaviour since version 1.5. See Issue matplotlib#8883 for more details.
@anntzer

This comment has been minimized.

Copy link
Contributor

commented Oct 16, 2017

Closed by #8897, thanks for the fix.

@anntzer anntzer closed this Oct 16, 2017

@QuLogic QuLogic added this to the 2.1 (next point release) milestone Oct 16, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.