Thanks, Francesco, but I already tried for both and that doesn't work either.

Cheers,

Am 26.04.2013 um 14:07 schrieb Francesco Montesano <franz.berges...@gmail.com>:

> 
> Il giorno 26/apr/2013 13:16, "Hackstein" <news.hackst...@gmx.net> ha scritto:
> >
> > Thanks, Ryan, this is (amost) exactly what I was looking  for. Now, I get 
> > the markers and their colors right, but I still have two problems:
> > The markers have a black edges, that I cannot get rid of. I've tried
> >
> > rect = Rectangle(..., ec=None)
> >
> > and also
> >
> > col.set=edgecolor(None)
> 
> I think that you have to use the string 'none' instead of None type. The 
> latter is used to use the default value for the variable (in you case black).
> 
> cheers
> Francesco
> >
> > and 'None', respectively, both with no effect whatsoever.
> >
> > The second problem is, that I cannot get the colorbar to work.
> > I tried
> >
> > sc = ax.add_collection(col)
> > plt.colorbar(sc)
> >
> > and
> >
> > plt.colobar(col)
> >
> > both do not work.
> > Any Ideas how to fix those two issues?
> >
> > Thanks,
> >
> > -Hackstein
> >
> >
> > > Message: 4
> > > Date: Thu, 25 Apr 2013 19:44:23 -0400
> > > From: Ryan Nelson <rnelsonc...@gmail.com>
> > > Subject: Re: [Matplotlib-users] Individual custom markers and colorbar
> > > To: matplotlib-users@lists.sourceforge.net
> > > Message-ID: <5179bfd7.7060...@gmail.com>
> > > Content-Type: text/plain; charset="iso-8859-1"
> > >
> > > Hackstein,
> > >
> > > Unfortunately, I'm not sure of an 'elegant' way to do what your asking
> > > with a single call to scatter. Others may know a better way. However,
> > > you can use rectangle patches and patch collections. (Requires a bit
> > > more code than scatter but is ultimately more flexible.)
> > >
> > > I think the example below does what you need, but with random numbers.
> > >
> > > Hope it helps a little.
> > >
> > > Ryan
> > >
> > > #######################
> > > import numpy as np
> > > import matplotlib.pyplot as plt
> > > from matplotlib.patches import Rectangle
> > > from matplotlib.collections import PatchCollection
> > >
> > > n = 100
> > >
> > > # Get your xy data points, which are the centers of the rectangles.
> > > xy = np.random.rand(n,2)
> > >
> > > # Set a fixed height
> > > height = 0.02
> > > # The variable widths of the rectangles
> > > widths = np.random.rand(n)*0.1
> > >
> > > # Get a color map and color values (normalized between 0 and 1)
> > > cmap = plt.cm.jet
> > > colors = np.random.rand(n)
> > >
> > > rects = []
> > > for p, w, c in zip(xy, widths, colors):
> > >     xpos = p[0] - w/2 # The x position will be half the width from the
> > > center
> > >     ypos = p[1] - height/2 # same for the y position, but with height
> > >     rect = Rectangle( (xpos, ypos), w, height ) # Create a rectangle
> > >     rects.append(rect) # Add the rectangle patch to our list
> > >
> > > # Create a collection from the rectangles
> > > col = PatchCollection(rects)
> > > # set the alpha for all rectangles
> > > col.set_alpha(0.3)
> > > # Set the colors using the colormap
> > > col.set_facecolor( cmap(colors) )
> > >
> > > # Make a figure and add the collection to the axis.
> > > ax = plt.subplot(111)
> > > ax.add_collection(col)
> > > plt.show()
> > >
> > > ###############################
> > >
> > >
> > > On 4/24/2013 5:35 PM, Hackstein wrote:
> > >>
> > >> Hi all,
> > >>
> > >> I am trying to get a scatter plot using a colormap. Additionally, I
> > >> need to define every marker for every data point individually -- each
> > >> being a rectangle with fixed height but varying width as a function of
> > >> the y-value. X and y being the data coordinates, z being a number to
> > >> be color coded with the colormap.
> > >>
> > >> Ideally, I would like to create a list of width and height values for
> > >> each data point and tell the scatter plot to use those.
> > >>
> > >> So far I got colormapped data with custom markers (simplified):
> > >>
> > >> [code]
> > >>
> > >> import numpy as np
> > >>
> > >> import matplotlib.pyplot as plt
> > >>
> > >> from pylab import *
> > >>
> > >> x = y = [1,2,3,4,5]
> > >>
> > >> z = [2,4,6,8,10]
> > >>
> > >> colors = cm.gnuplot2
> > >>
> > >> verts_vec = list(zip([-10.,10.,10.,-10.],[-5.,-5.,5.,5.]))
> > >>
> > >> fig = plt.figure(1, figsize=(14.40, 9.00))
> > >>
> > >> ax = fig.add_subplot(1,1,1)
> > >>
> > >> sc = ax.scatter(x, y, c=np.asarray(z), marker=None, edgecolor='None',
> > >> verts=verts_vec, cmap=colors, alpha=1.)
> > >>
> > >> plt.colorbar(sc, orientation='horizontal')
> > >>
> > >> plt.savefig('test.png', dpi=200)
> > >>
> > >> plt.close(1)
> > >>
> > >> [/code]
> > >>
> > >> But I need to define a marker size for each point, and I also need to
> > >> do that in axis scale values, not in points.
> > >>
> > >> I imagine giving verts a list of N*2 tuples instead of 2 tuples, N
> > >> being len(x), to define N individual markers.
> > >>
> > >> But when doing that I get the error that vertices.ndim==2.
> > >>
> > >> A less elegant way would be to plot every data point in an individual
> > >> scatter plot function, using a for-loop iterating over all data
> > >> points. Then, however, I see no way to apply a colormap and colorbar.
> > >>
> > >> What is the best way to accomplish that then?
> > >>
> > >> Thanks,
> > >>
> > >> -Hackstein
> > >>
> > >>
> > >>
> > >> ------------------------------------------------------------------------------
> > >> Try New Relic Now & We'll Send You this Cool Shirt
> > >> New Relic is the only SaaS-based application performance monitoring 
> > >> service
> > >> that delivers powerful full stack analytics. Optimize and monitor your
> > >> browser, app, & servers with just a few lines of code. Try New Relic
> > >> and get this awesome Nerd Life shirt! 
> > >> http://p.sf.net/sfu/newrelic_d2d_apr
> > >>
> > >>
> > >> _______________________________________________
> > >> Matplotlib-users mailing list
> > >> Matplotlib-users@lists.sourceforge.net
> > >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> > >
> > > -------------- next part --------------
> > > An HTML attachment was scrubbed...
> > >
> > > ------------------------------
> > >
> > > ------------------------------------------------------------------------------
> > > Try New Relic Now & We'll Send You this Cool Shirt
> > > New Relic is the only SaaS-based application performance monitoring 
> > > service
> > > that delivers powerful full stack analytics. Optimize and monitor your
> > > browser, app, & servers with just a few lines of code. Try New Relic
> > > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
> > >
> > > ------------------------------
> > >
> > > _______________________________________________
> > > Matplotlib-users mailing list
> > > Matplotlib-users@lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> > >
> > >
> > > End of Matplotlib-users Digest, Vol 83, Issue 23
> > > ************************************************
> >
> > ------------------------------------------------------------------------------
> > Try New Relic Now & We'll Send You this Cool Shirt
> > New Relic is the only SaaS-based application performance monitoring service
> > that delivers powerful full stack analytics. Optimize and monitor your
> > browser, app, & servers with just a few lines of code. Try New Relic
> > and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
> > _______________________________________________
> > Matplotlib-users mailing list
> > Matplotlib-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to