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

fill_between() no longer works with border linewidth of 0 #3929

Closed
rabryan opened this issue Dec 17, 2014 · 7 comments
Closed

fill_between() no longer works with border linewidth of 0 #3929

rabryan opened this issue Dec 17, 2014 · 7 comments
Milestone

Comments

@rabryan
Copy link

rabryan commented Dec 17, 2014

In 1.4.2, fill_between() does not always work when passing in lw=0 (to remove the border from the fill).

To reproduce, edit examples/pylab_examples/fill_between_demo.py and add argument "lw=0" in the first fill_between() call. Run the demo and notice how the fill no longer appears (in previous matplotlib versions it would appear -- but with no border).

@tacaswell tacaswell added this to the unassigned milestone Dec 18, 2014
@tacaswell
Copy link
Member

Can you try this on either the 1.4.x branch or the master branch?

Can you provide a minimal working example?

@tacaswell tacaswell modified the milestones: v1.4.3, unassigned Dec 18, 2014
@tacaswell tacaswell added the status: needs clarification Issues that need more information to resolve. label Dec 18, 2014
@rabryan
Copy link
Author

rabryan commented Dec 19, 2014

The behavior is the same on the master branch. Obviously its not a big deal since you can just set the linewidth to a very small value and it behaves almost identically to setting linewidth to 0.

Here is a small example:

#!/usr/bin/env python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.lines import Line2D

x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2*np.pi*x)
y2 = 1.2*np.sin(4*np.pi*x)

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=True)

ax1.fill_between(x, y1, y2, alpha = 0.2, lw=5)
ax1.set_ylabel('lw=5')

ax2.fill_between(x, y1, y2, alpha = 0.2, lw=0.01)
ax2.set_ylabel('lw=0.01')

ax3.fill_between(x, y1, y2, alpha = 0.2, lw=0)
ax3.set_ylabel('lw=0 (should still show fill)')
ax3.set_xlabel('x')
ax3.axes.add_line(Line2D(x, y1))

plt.show()

@tacaswell tacaswell removed the status: needs clarification Issues that need more information to resolve. label Dec 28, 2014
@tacaswell
Copy link
Member

I can not confirm this, the output looks correct to me on the master branch and the current 1.4.x brach (tweaked the code a bit to use plot instead of creating the artist by hand).

import matplotlib.pyplot as plt
import numpy as np


x = np.arange(0.0, 2, 0.01)
y1 = np.sin(2*np.pi*x)
y2 = 1.2*np.sin(4*np.pi*x)

fig, (ax1, ax2, ax3) = plt.subplots(3, 1, sharex=True)

ax1.fill_between(x, y1, y2, alpha = 0.2, lw=5)
ax1.set_ylabel('lw=5')

ax2.fill_between(x, y1, y2, alpha = 0.2, lw=0.01)
ax2.set_ylabel('lw=0.01')

ax3.fill_between(x, y1, y2, alpha = 0.2, lw=0)
ax3.set_ylabel('lw=0 (should still show fill)')
ax3.set_xlabel('x')
ax3.plot(x, y1, linestyle='--', color='k')

plt.show()

so

@atpage
Copy link

atpage commented Oct 22, 2015

This is broken for me as well. fill_between() with linewidth=0 was working in 1.4.0, but now in 1.4.2 it results in not plotting anything. Even trying to add a legend says that there were no labeled objects found. @tacaswell when I run your example, ax3 shows only the dashed line.

@mdboom
Copy link
Member

mdboom commented Oct 22, 2015

This has been fixed in 1.4.3

@atpage
Copy link

atpage commented Oct 22, 2015

Great, thanks.

@kaigaox
Copy link

kaigaox commented Aug 28, 2018

Great!

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

No branches or pull requests

5 participants