Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Reactivatingpyplot.subplot throws warning. #12513

Closed
Milestone
@ImportanceOfBeingErnest

Description

Bug report

Bug summary

Runningplt.subplot after the respective subplot has already been created shows a warning. This behaviour is expected forfig.add_subplot. However in pyplot this is to my knowledge the recommended way to activate a subplot, as seen fromthe tutorial.

Code for reproduction

The following is the code from the second code box in theWorking with multiple figures and axes section of the basic pyplot guide.

import matplotlib.pyplot as pltplt.figure(1)                # the first figureplt.subplot(211)             # the first subplot in the first figureplt.plot([1, 2, 3])plt.subplot(212)             # the second subplot in the first figureplt.plot([4, 5, 6])plt.figure(2)                # a second figureplt.plot([4, 5, 6])          # creates a subplot(111) by defaultplt.figure(1)                # figure 1 current; subplot(212) still currentplt.subplot(211)             # make subplot(211) in figure1 currentplt.title('Easy as 1, 2, 3') # subplot 211 title

Actual outcome

When being run it produces a warning.

MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance.

Expected outcome

No warning. Usingpyplot.subplot(211) should just activate the subplot, as described in the tutorial.

Alternatively, there needs to be another way to activate a subplot in pyplot (without having stored any handle to it previously).

Matplotlib version

  • Matplotlib version: 2.2.2, 3.0.0 (possibly others)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp