Skip to content

ParasiteAxes over plotting #9051

Closed
Closed

Description

@thehubbard

Bug report

Bug summary

Axis labels and ticks are being over plotted, i.e. plotted more than once when using ParasiteAxes and subplot host. This causes the output to appear bold along certain axes.

Code for reproduction

Modified version of https://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html to demonstrate location of over plotting.

from mpl_toolkits.axes_grid1 import host_subplot
import mpl_toolkits.axisartist as AA
import matplotlib.pyplot as plt


host = host_subplot(111, axes_class=AA.Axes)
plt.subplots_adjust(right=0.75)

par1 = host.twinx()
par2 = host.twinx()

offset = 60
new_fixed_axis = par2.get_grid_helper().new_fixed_axis
par2.axis["right"] = new_fixed_axis(loc="right",
                                    axes=par2,
                                    offset=(offset, 0))
    
par2.axis["right"].toggle(all=True)



host.set_xlim(0, 2)
host.set_ylim(0, 2)

host.set_xlabel("X-Overplotted")
host.set_ylabel("Y-Overplotted")
par1.set_ylabel("Axis is fine")
par2.set_ylabel("Axis is fine")

p1, = host.plot([0, 1, 2], [0, 1, 2])
p2, = par1.plot([0, 1, 2], [0, 3, 2])
p3, = par2.plot([0, 1, 2], [50, 30, 15])

par1.set_ylim(0, 4)
par2.set_ylim(1, 65)

host.axis["left"].label.set_color(p1.get_color())
par1.axis["right"].label.set_color(p2.get_color())
par2.axis["right"].label.set_color(p3.get_color())

plt.draw()
plt.show()

Actual outcome

As expected the x-axis and the left hand y-axis is bold due to over plotting.
over_plot

This is also seen in the figure in the documentation from
https://matplotlib.org/mpl_toolkits/axes_grid/users/overview.html#axisartist-with-parasiteaxes

Expected outcome

over_plot_142

This appeared to work fine in Matplotlib 1.4.2
http://matplotlib.org/1.4.2/mpl_toolkits/axes_grid/users/overview#axisartist-with-parasiteaxes

Thank you, in advance :)
Matplotlib version

  • Operating System: Ubuntu 16.04.3 LTS
  • Matplotlib Version: 2.0.2
  • Python Version: 2.7.12

Activity

  1. afvincent commented on Aug 30, 2017

    @afvincent
    Contributor

    @thehubbard Thank you for the detailed report!

    I can confirm that this issue still occurs on master branch too.

  2. added this to the milestone on Aug 30, 2017
  3. tacaswell commented on Aug 30, 2017

    @tacaswell
    Member

    I have a vague memory of a related bug with axes_grid.

    Somehow both the Axes base class + the axes_grid Axes sub-class are both trying to draw the ticks and labels.

  4. modified the milestones: , on Oct 9, 2017
  5. kmuehlbauer commented on Oct 4, 2018

    @kmuehlbauer
    Contributor

    Just to note because I stumbled over it. This is resolved by: #11688.

  6. ImportanceOfBeingErnest commented on Oct 4, 2018

    @ImportanceOfBeingErnest
    Member

    #11688 fixes this, but it hasn't been backported to the 2.2 branch. Is this desired?

  7. kmuehlbauer commented on Oct 4, 2018

    @kmuehlbauer
    Contributor

    @ImportanceOfBeingErnest I have no idea how much effort is needed to backport to 2.2 branch. For those who depend on 2.2 branch (eg. using py27) backporting seems the only solution.

  8. removed this from the future releases milestone on Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions