Good afternoon, I'm trying to plot surface current's data on a map thanks to a csv file. Here's my code :
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from pylab import *
# read CSV as a numpy array
data = mlab.csv2rec('datasets/mix.csv')
# print CSV file headers
print data.dtype.names
# load columns as vectors
data_x = data['longitude']
data_y = data['latitude']
data_u = data['x']
data_v = data['y']
U = cos(data_u)
V = sin(data_v)
# plot raw data
Q = quiver(data_x, data_y, U, V, color='black', units='width')
qk = quiverkey(Q, 0.5, 0.92, 2, '.', labelpos='W',
fontproperties={'weight': 'bold'})
title('Current Surface')
plt.show()
With a small part of that csv file (300 lines), my result contains arrows :

But when i want to model all my csv file, there are no arrows anymore, but points (which results in the map below):
Previous figure zoomed in to show there are no arrows:

Have you got any idea about this behaviour? Regards.
In the last image you have arrows, but they are so short that you cannot see the "tails". The problem is that in your second plot, you have too dense datapoints: The quiver command automatically scales the arrwos such that they do not overlap. If you then zoom in (I guess you zoomed in the window, not by selecting a smaller region in the script?), this scaling is not recalculated.
I would suggest to plot only every 10th or so datapoint (e.g. U[::10]), this should help. ALternatively, play around with the "scale" keyword argument:
http://matplotlib.org/api/pyplot_api.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With