Variable size plot symbols, variable hue plot colors in Python (MatPlotLib) ?

John Hunter jdhunter at ace.bsd.uchicago.edu
Thu Feb 10 15:49:36 EST 2005


>>>>> "Colombes" == Colombes  <DrColombes at yahoo.com> writes:

    Colombes> Using MatPlotLib plot function, is there a way to get
    Colombes> variable size plot symbols?  For example, using symbol
    Colombes> strings like 'o' (circle), 's' (square), 'x' (cross),
    Colombes> etc., is there a way to specify other plot symbols such
    Colombes> a small circle, Medium square, LARGE cross, etc.?

  plot(x, y, 'o', markersize=10) # big
  plot(x, y, 'o', markersize=20) # bigger

    Colombes> Similarly, using the MatPlotLib plot function, is there
    Colombes> a way to get variable hue (RGB-specified) plot colors?
    Colombes> For example, using symbol strings like 'b' (blue), 'g'
    Colombes> (green), 'red' (red), etc., is there a way to specify
    Colombes> other colors such as light blue, dark green, pink, etc.?

All legal html color names are supported

>>> plot(x, y, 'o', markersize=10, markerfacecolor='green', markeredgecolor='red') 

Eg

    lightblue            : #ADD8E6 	
    lightcoral           : #F08080 	
    lightcyan            : #E0FFFF 	
    lightgoldenrodyellow : #FAFAD2 	
    lightgreen           : #90EE90 	
    lightgrey            : #D3D3D3  	
    lightpink            : #FFB6C1 	
    lightsalmon          : #FFA07A 	
    lightseagreen        : #20B2AA 	
    lightskyblue         : #87CEFA 	
    lightslategray       : #778899  	
    lightsteelblue       : #B0C4DE 	
    lightyellow          : #FFFFE0 	


# or use aliases for less typing
>>> plot(x, y, 'o', ms=10, mfc='green', mec='red') 

# or rgba or hex
>>> plot(x, y, 'o', ms=10, mfc='#008000, mec=(1,0,0,1) )


    Colombes> Or perhaps is there some other Python MatPlotLib or
    Colombes> other Python module functions that allow variable size
    Colombes> plot symbols and variable hue plot colors in Python ?

The scatter command supports markers with varying sizes and colors.
screenshot with example code at
http://matplotlib.sourceforge.net/screenshots.html#scatter_demo2 .
Docs at
http://matplotlib.sourceforge.net/matplotlib.pylab.html#-scatter.

You might want to check out the tutorial and/or the user's guide.
Most of these issues are touched on there.

JDH



More information about the Python-list mailing list