>>>>> "Francesco" == Francesco Davide Calabrese <[EMAIL PROTECTED]> writes:
Francesco> Hi, the following simple code (in Matlab syntax): Francesco> x1 = [5, 6] y1 = [3, 2] bar([1,2], [x1; y1]) Francesco> produces a bar plot where two of the bars have a color Francesco> (let's say red) and the two other bars have another Francesco> color (let's say blue). I'd like to know whether it's Francesco> possible in matplotlib to plot the bars not simply with Francesco> a different color but with a different filling Francesco> pattern. So, for example, the blue bars filled with Francesco> vertical lines (or something else) and the red bars Francesco> filled with horizontal lines (or again something else). Francesco> Please, note that I'm not talking about the borders of Francesco> the bars. The reason why I need this feature is that I Francesco> have to clearly distinguish the bars also when they are Francesco> plotted in black and white, because many publications Francesco> can't be done in colors. The postscript backend supports this -- we call it "hatching". Unfortunately, the others do not yet. See the example at http://matplotlib.sf.net/examples/hatch_demo.py One could be clever with "imshow" and create arrays that have the hatching. In the example I wrote below I created a custom bar chart using gradient images. By adding horizontal, vertical, or diangonal lines to the arrays, or dots, one could support various hatching schemes. Here is the sample code for gradients that i wrote in response to an earlier post: from pylab import figure, show, nx, cm def gbar(ax, x, y, width=0.5, bottom=0): X = [[.6, .6],[.7,.7]] for left,top in zip(x, y): right = left+width ax.imshow(X, interpolation='bicubic', cmap=cm.Blues, extent=(left, right, bottom, top), alpha=1) fig = figure() xmin, xmax = xlim = 0,10 ymin, ymax = ylim = 0,1 ax = fig.add_subplot(111, xlim=xlim, ylim=ylim, autoscale_on=False) X = [[.6, .6],[.7,.7]] ax.imshow(X, interpolation='bicubic', cmap=cm.copper, extent=(xmin, xmax, ymin, ymax), alpha=1) N = 10 x = nx.arange(N)+0.25 y = nx.mlab.rand(N) gbar(ax, x, y, width=0.7) ax.set_aspect('normal') show() Ideally, we could do the work in Agg to support these hatched images.... JDH ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users