Description
Bug summary
I added some rectangular patches to a polar plot and found that they are not transformed correctly if those patches are the only objects plotted. However, if there is any plot like a polar bar plot on the same figure, all patches on this and following figures are displayed correctly. As you can see in the code below, this behaviour can be observed even if the "other" plot is removed immediately.
Please note that this will only work on a "fresh" IPython/python console where no bar/scatter/... plot has been done on a polar axis, as all subsequent attempts will produce the correct result.
Code for reproduction
Putting plt.show()
at the very end of the script instead of where it is in the snippet does not lead to the error described above.
# -*- coding: utf-8 -*-
import math
import matplotlib.pyplot as plt
from matplotlib import patches
def polarbug(bar_hack=False):
fig = plt.figure()
ax = fig.add_subplot(111, projection='polar')
# add quadrant as example
ax.add_patch(
patches.Rectangle(
(0, 1), width=math.pi*0.5, height=0.5
)
)
if bar_hack:
ax.bar(0, 1).remove()
ax.set_rmax(2)
plt.show()
if __name__ == '__main__':
polarbug()
polarbug(bar_hack=True)
polarbug()
Actual outcome
With (left) and without (right) ax.set_rmax(2)
:
Figure 1
Expected outcome
All three figures should look the same.
Matplotlib version
- Operating System: Windows 10 Pro x64
- Matplotlib Version: 2.0.0 (conda 4.3.16)
- Python Version: 2.7.13 64bit
- Other Libraries: math or numpy (for pi only)