在构建了一个自定义样式并将其保存在“.mplstyle”文件夹中之后,我将这个mplstyle导入到一个新的脚本中。不幸的是我有一些错误。在
home/local/lib/python2.7/site-packages/matplotlib/__init__.py:1102: UserWarning: Bad val "[3.7, 1.6]" on line #183
"lines.dashed_pattern : [3.7, 1.6]
"
in file "/home/plotting_tools/codepan.mplstyle"
Key lines.dashed_pattern: Could not convert all entries to floats
(val, error_details, msg))
/home/local/lib/python2.7/site-packages/matplotlib/__init__.py:1102: UserWarning: Bad val "[1.0, 1.65]" on line #184
"lines.dotted_pattern : [1.0, 1.65]
"
in file "/home/plotting_tools/codepan.mplstyle"
Key lines.dotted_pattern: Could not convert all entries to floats
(val, error_details, msg))
AttributeErrorTraceback (most recent call last)
/home/local/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
332 pass
333 else:
--> 334 return printer(obj)
335 # Finally look for special method names
336 method = get_real_method(obj, self.print_method)
/home/local/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
239
240 if 'png' in formats:
--> 241 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
242 if 'retina' in formats or 'png2x' in formats:
243 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))
/home/local/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
123
124 bytes_io = BytesIO()
--> 125 fig.canvas.print_figure(bytes_io, **kw)
126 data = bytes_io.getvalue()
127 if fmt == 'svg':
/home/local/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
2210 orientation=orientation,
2211 dryrun=True,
-> 2212 **kwargs)
2213 renderer = self.figure._cachedRenderer
2214 bbox_inches = self.figure.get_tightbbox(renderer)
/home/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
511
512 def print_png(self, filename_or_obj, *args, **kwargs):
--> 513 FigureCanvasAgg.draw(self)
514 renderer = self.get_renderer()
515 original_dpi = renderer.dpi
/home/local/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in draw(self)
431 # if toolbar:
432 # toolbar.set_cursor(cursors.WAIT)
--> 433 self.figure.draw(self.renderer)
434 # A GUI class may be need to update a window using this draw, so
435 # don't forget to call the superclass.
/home/local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
53 renderer.start_filter()
54
---> 55 return draw(artist, renderer, *args, **kwargs)
56 finally:
57 if artist.get_agg_filter() is not None:
/home/local/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)
1470
1471 if self.frameon:
-> 1472 self.patch.draw(renderer)
1473
1474 mimage._draw_list_compositing_images(
/home/local/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
53 renderer.start_filter()
54
---> 55 return draw(artist, renderer, *args, **kwargs)
56 finally:
57 if artist.get_agg_filter() is not None:
/home/local/lib/python2.7/site-packages/matplotlib/patches.pyc in draw(self, renderer)
556 renderer = PathEffectRenderer(self.get_path_effects(), renderer)
557
--> 558 renderer.draw_path(gc, tpath, affine, rgbFace)
559
560 gc.restore()
/home/local/lib/python2.7/site-packages/matplotlib/patheffects.pyc in draw_path(self, gc, tpath, affine, rgbFace)
107 def draw_path(self, gc, tpath, affine, rgbFace=None):
108 for path_effect in self._path_effects:
--> 109 path_effect.draw_path(self._renderer, gc, tpath, affine,
110 rgbFace)
111
AttributeError: 'unicode' object has no attribute 'draw_path'<Figure size 432x288 with 1 Axes>
我怀疑这与我如何格式化“.mplstyle”文件有关,但我不太确定。如果您需要有关我的计算机或我正在运行的脚本的更多信息,请告诉我。在
编辑
这是我使用的代码
^{pr2}$下面是mplstyle文件的一个片段
lines.dashdot_pattern : [6.4, 1.6, 1.0, 1.6]
lines.dashed_pattern : [3.7, 1.6]
lines.dotted_pattern : [1.0, 1.65]
你想删除这些行中的方括号
也就是说,它们应该看起来像:
例如,请参见
classic.mplstyle
示例页中的here。在相关问题 更多 >
编程相关推荐