-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Too small axis arrow when savefig to png #7489
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
Comments
I also noticed that these arrows are small when use |
@afvincent, I will try beta soon and will give answer. Thanks. |
@AndreWin Did you have the opportunity to check with the new RC1 of matplotlib 2.0? It seems to me that the problem of the DPI-dependent arrow head size is not present anymore. However, during my own tests with RC1, the tick direction was not outward (but there is an easy fix for that) and the grid behavior was weird: Here is a possible workaround: # -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid.axislines import SubplotZero
fig = plt.figure()
ax = SubplotZero(fig, 111)
_ = fig.add_subplot(ax)
for direction in ["xzero", "yzero"]:
ax.axis[direction].set_visible(True)
ax.axis[direction].set_axisline_style("->")
# Set outward ticks
ax.axis[direction].major_ticks.set_tick_out(True)
ax.axis[direction].minor_ticks.set_tick_out(True)
for direction in ["top", "bottom", "left", "right"]:
ax.axis[direction].set_visible(False)
ax.axis["yzero"].set_axis_direction("left")
plt.plot([0,1], [0,1], c="blue", lw=2)
_ = plt.title(u"График")
_ = plt.xlabel(u"Ось x")
_ = plt.ylabel(u"Ось y")
ax.minorticks_on()
# Workaround: as ax.grid(True) seems to be buggy, manually create a custom grid
# 1- Set the desired lower bound for each axis (here 0.0)
xlims = [0.0, ax.get_xlim()[1]]
ylims = [0.0, ax.get_ylim()[1]]
# 2- For each axis, get the (major) relevant tick locations
# and draw a collection of lines
grid_style = dict(color='Black', lw=0.5, linestyles=':') # 1.5.3-like style
xticks = [val for val in ax.xaxis.get_ticklocs() if xlims[0] < val <= xlims[1]]
ax.vlines(xticks, ymin=ylims[0], ymax=ylims[1], **grid_style)
yticks = [val for val in ax.yaxis.get_ticklocs() if ylims[0] < val <= ylims[1]]
ax.hlines(yticks, xmin=xlims[0], xmax=xlims[1], **grid_style)
for ext in ['png', 'svg', 'pdf']:
plt.savefig("workaround_test_chart."+ext, dpi=300)
plt.show() |
Hello, @afvincent. Sorry that didn't answer for a long time. I didn't find how to install beta version of maptlotlib in my environment created with conda. |
@AndreWin http://matplotlib.org/style_changes.html (link in the banner on the top of all matplotlib.org pages now). |
@tacaswell, many thanks :) |
I can reproduce the xlabel/ylabel issue, I suspect there is a bug in from mpl_toolkits.axes_grid.axislines import SubplotZero but I have not tracked it down. I can not reproduce this xlabel/ylabel issue with As a side note, the default font supports Cyrillic out of the box in 2.0. |
I'm not sure if this is expected when using ax.axis['xzero'].set_label("Ось x")
ax.axis['yzero'].set_label("Ось y") to get the correct labels. |
@tacaswell, when I replaced
to
I got error
Full code:
Really? Cool!!!! ^_^ |
@QuLogic, your workaround works nice! Many thanks! :) |
Closing as fixed in 2.0, but created a new issue to track the See http://matplotlib.org/2.0.0rc1/users/dflt_style_changes.html#normal-text re the font. |
Hello!
My code:
My matplotlibrc file in
MPLCONFIGDIR
:I works on Windows 8.1 64bit. I use
Python 3.5.2 |Continuum Analytics, Inc.| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
in environmet, created with conda.Matplotlib version is 1.5.3
When I see files created with matplotlib I see that arrows on axis ends are normal in svg and pdf files but too small in png file.
In svg file:
In png file:
Maybe it's bug.
Best regards, Andrey.
The text was updated successfully, but these errors were encountered: