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):
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)
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