|
From: Matt F. <ma...@nm...> - 2011-04-07 22:56:00
|
Hi, i am farily new to matplotlib so my question might be fairly basic. I would like to be able to set certain default values at the beginning of my script. The way i did this with the other values is via changing the value stored in rcparams. So something like: import matplotlib.pyplot as mpl mpl.rcParams['lines.markersize'] = 20 But i would like to set the markerfacecolor in such a way but it is not included in rcParams. I would really like to avoid setting it in each individual plot call. Is there a way to change the default at the start of the script? thanks matt |
|
From: Paul I. <piv...@gm...> - 2011-04-08 00:50:12
|
Matt Funk, on 2011-04-07 16:52, wrote: > Hi, > i am farily new to matplotlib so my question might be fairly basic. I would > like to be able to set certain default values at the beginning of my script. > The way i did this with the other values is via changing the value stored in > rcparams. So something like: > import matplotlib.pyplot as mpl > mpl.rcParams['lines.markersize'] = 20 > > But i would like to set the markerfacecolor in such a way but it is not > included in rcParams. I would really like to avoid setting it in each > individual plot call. > > Is there a way to change the default at the start of the script? Hi Matt, this depends on how you're plotting. If you're just using plt.plot - it defers to cycling through the rcParams['axes.color_cycle'] - so just set that to one value before starting your plots.. old_color_cycle = rcParams['axes.color_cycle'] rcParams['axes.color_cycle'] = 'purple' # cue Gogol Bordello plt.figure() ax = plt.subplot(111) ax.plot(range(10),'o', markersize=40) ax.plot(np.random.rand(10),'o', markersize=40) ax.plot(np.random.rand(10)*10,'o', markersize=40) # restore color_cycle just for this axes ax._get_lines.set_color_cycle(old_color_cycle) ax.plot(range(20,30), range(10),'o', markersize=40) ax.plot(range(20,30), np.random.rand(10),'o', markersize=40) ax.plot(range(20,30), np.random.rand(10)*10,'o', markersize=40) # restore old cycle for all new axes rcParams['axes.color_cycle'] = old_color_cycle -- If, on the other hand, you're using scatter, there isn't currently a way of doing the same, since scatter just uses 'b' as the default parameter for color. This should probably be changed to act the same way plot does, but that isn't currently implemented. This would be a good first patch for a newcomer -- and would make matplotlib more consistent. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 |
|
From: Matt F. <ma...@nm...> - 2011-04-08 20:59:48
|
Hi Paul, thanks for the response. Emmhh, i am not sure what's going on since what you are saying matches what's listed at http://matplotlib.sourceforge.net/users/customizing.html. The problem is that when i try it I get a key error, correspondingly, when i print rcParams i cannot find axes.color_cycle key: So printing rcParams gives: print mpl.rcParams {'figure.subplot.right': 0.90000000000000002, 'mathtext.cal': 'cursive', 'font.fantasy': ['Comic Sans MS', 'Chicago', 'Charcoal', 'ImpactWestern', 'fantasy'], 'xtick.minor.pad': 4, 'tk.pythoninspect': False, 'image.aspect': 'equal', 'font.cursive': ['Apple Chancery', 'Textile', 'Zapf Chancery', 'Sand', 'cursive'], 'figure.subplot.hspace': 0.20000000000000001, 'xtick.direction': 'out', 'axes.facecolor': 'w', 'mathtext.fontset': 'cm', 'ytick.direction': 'out', 'svg.image_inline': True, 'lines.markersize': 10.0, 'figure.dpi': 80, 'text.usetex': True, 'text.fontangle': 'normal', 'patch.edgecolor': 'k', 'legend.labelspacing': 0.5, 'ps.useafm': False, 'mathtext.bf': 'serif:bold', 'lines.solid_joinstyle': 'round', 'font.monospace': ['Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Andale Mono', 'Nimbus Mono L', 'Courier New', 'Courier', 'Fixed', 'Terminal', 'monospace'], 'xtick.minor.size': 2, 'axes.formatter.limits': [-7, 7], 'figure.subplot.wspace': 0.20000000000000001, 'savefig.edgecolor': 'w', 'text.fontvariant': 'normal', 'image.cmap': 'jet', 'axes.edgecolor': 'k', 'tk.window_focus': False, 'image.origin': 'upper', 'text.fontsize': 'medium', 'font.serif': ['Bitstream Vera Serif', 'DejaVu Serif', 'New Century Schoolbook', 'Century Schoolbook L', 'Utopia', 'ITC Bookman', 'Bookman', 'Nimbus Roman No9 L', 'Times New Roman', 'Times', 'Palatino', 'Charter', 'serif'], 'savefig.facecolor': 'w', 'maskedarray': 'obsolete', 'ytick.minor.size': 2, 'numerix': 'obsolete', 'font.stretch': 'normal', 'text.dvipnghack': None, 'ytick.color': 'k', 'lines.linestyle': '-', 'xtick.color': 'k', 'xtick.major.pad': 4, 'text.fontweight': 'normal', 'patch.facecolor': 'b', 'figure.figsize': [8.0, 6.0], 'axes.linewidth': 1.0, 'legend.handletextpad': 0.80000000000000004, 'mathtext.fallback_to_cm': True, 'lines.linewidth': 1.0, 'savefig.dpi': 100, 'verbose.fileo': 'sys.stdout', 'svg.image_noscale': False, 'docstring.hardcopy': False, 'font.size': 24.0, 'ps.fonttype': 3, 'path.simplify': True, 'polaraxes.grid': True, 'toolbar': 'toolbar2', 'pdf.compression': 6, 'grid.linewidth': 0.5, 'figure.autolayout': False, 'figure.facecolor': '0.75', 'ps.usedistiller': False, 'legend.isaxes': True, 'figure.edgecolor': 'w', 'mathtext.tt': 'monospace', 'contour.negative_linestyle': 'dashed', 'image.interpolation': 'bilinear', 'lines.markeredgewidth': 1.5, 'axes3d.grid': True, 'lines.marker': 'None', 'legend.shadow': False, 'axes.titlesize': 24.0, 'backend': 'TkAgg', 'xtick.major.size': 4, 'legend.fontsize': 24.0, 'lines.solid_capstyle': 'projecting', 'mathtext.it': 'serif:italic', 'font.variant': 'normal', 'xtick.labelsize': 'medium', 'axes.unicode_minus': True, 'ps.distiller.res': 6000, 'pdf.fonttype': 3, 'patch.linewidth': 1.0, 'pdf.inheritcolor': False, 'lines.dash_capstyle': 'butt', 'lines.color': 'b', 'text.latex.preview': False, 'figure.subplot.top': 0.90000000000000002, 'pdf.use14corefonts': False, 'legend.markerscale': 1.0, 'patch.antialiased': True, 'font.style': 'normal', 'backend_fallback': True, 'legend.fancybox': True, 'grid.linestyle': ':', 'axes.labelcolor': 'k', 'text.color': 'k', 'mathtext.rm': 'serif', 'legend.loc': 'upper right', 'interactive': False, 'cairo.format': 'png', 'savefig.orientation': 'portrait', 'axes.axisbelow': False, 'ytick.major.size': 4, 'axes.grid': False, 'plugins.directory': '.matplotlib_plugins', 'grid.color': 'k', 'timezone': 'UTC', 'ytick.major.pad': 4, 'legend.borderpad': 0.40000000000000002, 'lines.dash_joinstyle': 'round', 'datapath': '/usr/share/matplotlib/mpl-data', 'lines.antialiased': True, 'text.latex.unicode': False, 'image.lut': 256, 'units': False, 'figure.subplot.bottom': 0.10000000000000001, 'text.latex.preamble': [''], 'legend.numpoints': 2, 'legend.handlelength': 2.0, 'font.sans-serif': ['Arial'], 'font.family': 'sans-serif', 'axes.labelsize': 24.0, 'ytick.minor.pad': 4, 'legend.borderaxespad': 0.5, 'mathtext.sf': 'sans\\- serif', 'axes.hold': True, 'verbose.level': 'silent', 'mathtext.default': 'it', 'figure.subplot.left': 0.125, 'legend.columnspacing': 2.0, 'text.fontstyle': 'normal', 'font.weight': 'normal', 'image.resample': False, 'agg.path.chunksize': 0, 'path.simplify_threshold': 0.1111111111111111, 'ytick.labelsize': 'medium', 'ps.papersize': 'letter', 'svg.embed_char_paths': True} (sorry for the long post). Anything obvious that i am doing wrong? I am using: Python 2.6.6 mpl.__version__ = 0.99.3 thanks matt On Thursday, April 07, 2011, Paul Ivanov wrote: > Matt Funk, on 2011-04-07 16:52, wrote: > > Hi, > > i am farily new to matplotlib so my question might be fairly basic. I > > would like to be able to set certain default values at the beginning of > > my script. The way i did this with the other values is via changing the > > value stored in rcparams. So something like: > > import matplotlib.pyplot as mpl > > mpl.rcParams['lines.markersize'] = 20 > > > > But i would like to set the markerfacecolor in such a way but it is not > > included in rcParams. I would really like to avoid setting it in each > > individual plot call. > > > > Is there a way to change the default at the start of the script? > > Hi Matt, > > this depends on how you're plotting. > > If you're just using plt.plot - it defers to cycling through the > rcParams['axes.color_cycle'] - so just set that to one value > before starting your plots.. > > old_color_cycle = rcParams['axes.color_cycle'] > rcParams['axes.color_cycle'] = 'purple' # cue Gogol Bordello > plt.figure() > ax = plt.subplot(111) > > ax.plot(range(10),'o', markersize=40) > ax.plot(np.random.rand(10),'o', markersize=40) > ax.plot(np.random.rand(10)*10,'o', markersize=40) > > # restore color_cycle just for this axes > ax._get_lines.set_color_cycle(old_color_cycle) > ax.plot(range(20,30), range(10),'o', markersize=40) > ax.plot(range(20,30), np.random.rand(10),'o', markersize=40) > ax.plot(range(20,30), np.random.rand(10)*10,'o', markersize=40) > > # restore old cycle for all new axes > rcParams['axes.color_cycle'] = old_color_cycle > -- > > If, on the other hand, you're using scatter, there isn't > currently a way of doing the same, since scatter just uses 'b' as > the default parameter for color. > > This should probably be changed to act the same way plot does, > but that isn't currently implemented. This would be a good first > patch for a newcomer -- and would make matplotlib more consistent. > > best, |
|
From: Paul I. <piv...@gm...> - 2011-04-09 00:58:37
|
Hi Matt, Matt Funk, on 2011-04-08 14:56, wrote: > mpl.__version__ = 0.99.3 ah - this would do it - that axis parameter was added by Eric Firing on 2010-01-03 - but it didn't go into the 0.99 series - it went straight to trunk - so you'll have to get at least matplotlib 1.0 to gain that functionality. best, -- Paul Ivanov 314 address only used for lists, off-list direct email at: http://pirsquared.org | GPG/PGP key id: 0x0F3E28F7 |
|
From: Eric F. <ef...@ha...> - 2011-04-08 23:51:32
|
On 04/08/2011 10:56 AM, Matt Funk wrote: > Hi Paul, > > thanks for the response. Emmhh, i am not sure what's going on since what you > are saying matches what's listed at > http://matplotlib.sourceforge.net/users/customizing.html. The problem is that > when i try it I get a key error, correspondingly, when i print rcParams i > cannot find axes.color_cycle key: It is quite new, so your mpl version is too old to have it. Eric > > So printing rcParams gives: > print mpl.rcParams > {'figure.subplot.right': 0.90000000000000002, 'mathtext.cal': 'cursive', > 'font.fantasy': ['Comic Sans MS', 'Chicago', 'Charcoal', 'ImpactWestern', > 'fantasy'], 'xtick.minor.pad': 4, 'tk.pythoninspect': False, 'image.aspect': > 'equal', 'font.cursive': ['Apple Chancery', 'Textile', 'Zapf Chancery', > 'Sand', 'cursive'], 'figure.subplot.hspace': 0.20000000000000001, > 'xtick.direction': 'out', 'axes.facecolor': 'w', 'mathtext.fontset': 'cm', > 'ytick.direction': 'out', 'svg.image_inline': True, 'lines.markersize': 10.0, > 'figure.dpi': 80, 'text.usetex': True, 'text.fontangle': 'normal', > 'patch.edgecolor': 'k', 'legend.labelspacing': 0.5, 'ps.useafm': False, > 'mathtext.bf': 'serif:bold', 'lines.solid_joinstyle': 'round', > 'font.monospace': ['Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Andale > Mono', 'Nimbus Mono L', 'Courier New', 'Courier', 'Fixed', 'Terminal', > 'monospace'], 'xtick.minor.size': 2, 'axes.formatter.limits': [-7, 7], > 'figure.subplot.wspace': 0.20000000000000001, 'savefig.edgecolor': 'w', > 'text.fontvariant': 'normal', 'image.cmap': 'jet', 'axes.edgecolor': 'k', > 'tk.window_focus': False, 'image.origin': 'upper', 'text.fontsize': 'medium', > 'font.serif': ['Bitstream Vera Serif', 'DejaVu Serif', 'New Century > Schoolbook', 'Century Schoolbook L', 'Utopia', 'ITC Bookman', 'Bookman', > 'Nimbus Roman No9 L', 'Times New Roman', 'Times', 'Palatino', 'Charter', > 'serif'], 'savefig.facecolor': 'w', 'maskedarray': 'obsolete', > 'ytick.minor.size': 2, 'numerix': 'obsolete', 'font.stretch': 'normal', > 'text.dvipnghack': None, 'ytick.color': 'k', 'lines.linestyle': '-', > 'xtick.color': 'k', 'xtick.major.pad': 4, 'text.fontweight': 'normal', > 'patch.facecolor': 'b', 'figure.figsize': [8.0, 6.0], 'axes.linewidth': 1.0, > 'legend.handletextpad': 0.80000000000000004, 'mathtext.fallback_to_cm': True, > 'lines.linewidth': 1.0, 'savefig.dpi': 100, 'verbose.fileo': 'sys.stdout', > 'svg.image_noscale': False, 'docstring.hardcopy': False, 'font.size': 24.0, > 'ps.fonttype': 3, 'path.simplify': True, 'polaraxes.grid': True, 'toolbar': > 'toolbar2', 'pdf.compression': 6, 'grid.linewidth': 0.5, 'figure.autolayout': > False, 'figure.facecolor': '0.75', 'ps.usedistiller': False, 'legend.isaxes': > True, 'figure.edgecolor': 'w', 'mathtext.tt': 'monospace', > 'contour.negative_linestyle': 'dashed', 'image.interpolation': 'bilinear', > 'lines.markeredgewidth': 1.5, 'axes3d.grid': True, 'lines.marker': 'None', > 'legend.shadow': False, 'axes.titlesize': 24.0, 'backend': 'TkAgg', > 'xtick.major.size': 4, 'legend.fontsize': 24.0, 'lines.solid_capstyle': > 'projecting', 'mathtext.it': 'serif:italic', 'font.variant': 'normal', > 'xtick.labelsize': 'medium', 'axes.unicode_minus': True, 'ps.distiller.res': > 6000, 'pdf.fonttype': 3, 'patch.linewidth': 1.0, 'pdf.inheritcolor': False, > 'lines.dash_capstyle': 'butt', 'lines.color': 'b', 'text.latex.preview': > False, 'figure.subplot.top': 0.90000000000000002, 'pdf.use14corefonts': False, > 'legend.markerscale': 1.0, 'patch.antialiased': True, 'font.style': 'normal', > 'backend_fallback': True, 'legend.fancybox': True, 'grid.linestyle': ':', > 'axes.labelcolor': 'k', 'text.color': 'k', 'mathtext.rm': 'serif', > 'legend.loc': 'upper right', 'interactive': False, 'cairo.format': 'png', > 'savefig.orientation': 'portrait', 'axes.axisbelow': False, 'ytick.major.size': > 4, 'axes.grid': False, 'plugins.directory': '.matplotlib_plugins', > 'grid.color': 'k', 'timezone': 'UTC', 'ytick.major.pad': 4, > 'legend.borderpad': 0.40000000000000002, 'lines.dash_joinstyle': 'round', > 'datapath': '/usr/share/matplotlib/mpl-data', 'lines.antialiased': True, > 'text.latex.unicode': False, 'image.lut': 256, 'units': False, > 'figure.subplot.bottom': 0.10000000000000001, 'text.latex.preamble': [''], > 'legend.numpoints': 2, 'legend.handlelength': 2.0, 'font.sans-serif': > ['Arial'], 'font.family': 'sans-serif', 'axes.labelsize': 24.0, > 'ytick.minor.pad': 4, 'legend.borderaxespad': 0.5, 'mathtext.sf': 'sans\\- > serif', 'axes.hold': True, 'verbose.level': 'silent', 'mathtext.default': > 'it', 'figure.subplot.left': 0.125, 'legend.columnspacing': 2.0, > 'text.fontstyle': 'normal', 'font.weight': 'normal', 'image.resample': False, > 'agg.path.chunksize': 0, 'path.simplify_threshold': 0.1111111111111111, > 'ytick.labelsize': 'medium', 'ps.papersize': 'letter', 'svg.embed_char_paths': > True} > > (sorry for the long post). > Anything obvious that i am doing wrong? I am using: > Python 2.6.6 > mpl.__version__ = 0.99.3 > > thanks > matt > > > On Thursday, April 07, 2011, Paul Ivanov wrote: >> Matt Funk, on 2011-04-07 16:52, wrote: >>> Hi, >>> i am farily new to matplotlib so my question might be fairly basic. I >>> would like to be able to set certain default values at the beginning of >>> my script. The way i did this with the other values is via changing the >>> value stored in rcparams. So something like: >>> import matplotlib.pyplot as mpl >>> mpl.rcParams['lines.markersize'] = 20 >>> >>> But i would like to set the markerfacecolor in such a way but it is not >>> included in rcParams. I would really like to avoid setting it in each >>> individual plot call. >>> >>> Is there a way to change the default at the start of the script? >> >> Hi Matt, >> >> this depends on how you're plotting. >> >> If you're just using plt.plot - it defers to cycling through the >> rcParams['axes.color_cycle'] - so just set that to one value >> before starting your plots.. >> >> old_color_cycle = rcParams['axes.color_cycle'] >> rcParams['axes.color_cycle'] = 'purple' # cue Gogol Bordello >> plt.figure() >> ax = plt.subplot(111) >> >> ax.plot(range(10),'o', markersize=40) >> ax.plot(np.random.rand(10),'o', markersize=40) >> ax.plot(np.random.rand(10)*10,'o', markersize=40) >> >> # restore color_cycle just for this axes >> ax._get_lines.set_color_cycle(old_color_cycle) >> ax.plot(range(20,30), range(10),'o', markersize=40) >> ax.plot(range(20,30), np.random.rand(10),'o', markersize=40) >> ax.plot(range(20,30), np.random.rand(10)*10,'o', markersize=40) >> >> # restore old cycle for all new axes >> rcParams['axes.color_cycle'] = old_color_cycle >> -- >> >> If, on the other hand, you're using scatter, there isn't >> currently a way of doing the same, since scatter just uses 'b' as >> the default parameter for color. >> >> This should probably be changed to act the same way plot does, >> but that isn't currently implemented. This would be a good first >> patch for a newcomer -- and would make matplotlib more consistent. >> >> best, > > > ------------------------------------------------------------------------------ > Xperia(TM) PLAY > It's a major breakthrough. An authentic gaming > smartphone on the nation's most reliable network. > And it wants your games. > http://p.sf.net/sfu/verizon-sfdev > _______________________________________________ > Matplotlib-users mailing list > Mat...@li... > https://lists.sourceforge.net/lists/listinfo/matplotlib-users |