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

xkcd plots with background color have white outlines for text and axes spines #3843

Closed
ilivni opened this issue Nov 24, 2014 · 3 comments
Closed
Assignees

Comments

@ilivni
Copy link
Contributor

ilivni commented Nov 24, 2014

Hi - I was messing butchering a plot using a solarized color theme (similar to ggplot2) and found that the text and the axes spines had white padding around them. Example of chart and code below: (if this is incomplete or incorrect please let me know)

Chart:

whitepadding

Code:

base3='#fdf6e3'

with plt.xkcd():
      some plot data ...
      plt.title(title, color=magenta, size=14)
      plt.xticks(rotation=45)
      ax.spines['bottom'].set_color(base3)
      ax.spines['top'].set_color(base3)
      ax.spines['left'].set_color(base3)
      ax.spines['right'].set_color(base3)
      ax.grid(False)
@tacaswell tacaswell added this to the unassigned milestone Nov 24, 2014
@ilivni
Copy link
Contributor Author

ilivni commented Nov 27, 2014

Update: I tried doing a work around by saving the plot to a .png with transparent=True .

with plt.xkcd():
      ... make a line plot
      ... Solarize - **No background**
      ... Annotate
      ... rotate xticks 45 degrees
      ....plt.savefig('some file Path' +'CumSum.png', transparent=True)

This is what I get when the .png is posted to the website with a Solarized theme.

bug_xkcd

The same behaviour as when a background is applied using matplolib.

Let me know if this helps and where I can take a look to maybe "fix"

@pelson
Copy link
Member

pelson commented Nov 28, 2014

The white outline occurs on the line:

patheffects.withStroke(linewidth=4, foreground="w")]

If you want to change the outline, simply change your rcParams after enabling xkcd to something like:

from matplotlib import patheffects
rcParams['path.effects'] = [patheffects.withStroke(linewidth=4, foreground=magneta)]

@ilivni
Copy link
Contributor Author

ilivni commented Nov 30, 2014

Perfect. Yes. Actually I just set linewidth=0

Thanks and sorry for opening a nonbug

@ilivni ilivni closed this as completed Nov 30, 2014
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

4 participants