Python matplotlib中的RC变量不';不适用于web应用程序中的图形、轴
我正在尝试在一个web应用程序中为matplotlib设置线宽,该应用程序使用Python matplotlib中的RC变量不';不适用于web应用程序中的图形、轴,python,pylons,matplotlib,Python,Pylons,Matplotlib,我正在尝试在一个web应用程序中为matplotlib设置线宽,该应用程序使用 matplotlib.rc('lines', linewidth=0.5) 在交互模式下使用matplotlib时,这很好,但在我的web应用程序中,它没有任何效果,而获得正确线宽的唯一方法是在各个调用上提供参数,即: vals = map(itemgetter(1), sorted(series1.items(), reverse=True)) group1_rects = ax.barh(ind, vals,
matplotlib.rc('lines', linewidth=0.5)
在交互模式下使用matplotlib时,这很好,但在我的web应用程序中,它没有任何效果,而获得正确线宽的唯一方法是在各个调用上提供参数,即:
vals = map(itemgetter(1), sorted(series1.items(), reverse=True))
group1_rects = ax.barh(ind, vals, width, color='r', snap=True, linewidth=0.5)
vals = map(itemgetter(1), sorted(series2.items(), reverse=True))
group2_rects = ax.barh(ind+width, vals, width, color='b', linewidth=0.5)
让matplotlib.rc调用在web应用程序中工作是否涉及一些技巧
我用于绘制图形的代码如下所示:
@contextmanager
def render_plot(w=8,h=8):
fig = Figure(figsize=(w,h))
canvas = FigureCanvas(fig)
response.content_type = 'image/png'
#Here is where I hope to put RC settings
matplotlib.rc('lines', linewidth=0.5)
yield fig
s = StringIO()
canvas.print_figure(s)
response.content = s.getvalue()
你发布的内容应该有用。作为参考,以下内容对我使用Python2.6和matplotlib 1.0非常有用
from contextlib import contextmanager
import matplotlib as mpl
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
@contextmanager
def render_plot(w=8,h=8):
fig = Figure(figsize=(w,h))
canvas = FigureCanvas(fig)
mpl.rc('lines', linewidth=5)
yield fig
s = file('temp.png', 'w')
canvas.print_figure(s)
with render_plot() as fig:
ax = fig.add_subplot(111)
ax.plot(range(10))
这个例子在你的系统上有效吗 你发布的内容应该有用。作为参考,以下内容对我使用Python2.6和matplotlib 1.0非常有用
from contextlib import contextmanager
import matplotlib as mpl
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure
@contextmanager
def render_plot(w=8,h=8):
fig = Figure(figsize=(w,h))
canvas = FigureCanvas(fig)
mpl.rc('lines', linewidth=5)
yield fig
s = file('temp.png', 'w')
canvas.print_figure(s)
with render_plot() as fig:
ax = fig.add_subplot(111)
ax.plot(range(10))
这个例子在你的系统上有效吗 有什么想法是matplotlib/pyplot上下文中的
rc
意思吗?有什么想法是matplotlib/pyplot上下文中的rc
意思吗?