Python, matplotlib plot 2D histogram on polar axis.


by funcosed
Tags: histogram2d, matplotlib, polar, python
funcosed
funcosed is offline
#1
Nov21-12, 12:12 PM
P: 36
Any python/matplotlib experts out there?? This one has been driving me crazy all day. I have three vectors, azimuth, frequency and power, which I would like to histogram and plot on a polar axis. I can plot a scatter plot this way no problem but the histogram gets messed up somehow. An example is below, anybody know how to do this properly??

import random
import numpy as np
import matplotlib.pyplot as plt

baz = np.zeros((20))
freq = np.zeros((20))
pwr = np.zeros((20))
for x in range(20):
baz[x] = random.randint(20,25)*10
freq[x] = random.randint(1,10)*10
pwr[x] = random.randint(-10,-1)*10

baz = baz*np.pi/180.

abins = np.linspace(0,2*np.pi,360)
sbins = np.linspace(1, 100)

H, xedges, yedges = np.histogram2d(baz, freq, bins=(abins,sbins), weights=pwr)

plt.figure(figsize=(14,14))
plt.subplot(111, polar=True)
#plt.scatter(baz, freq, c=pwr)
plt.pcolormesh(H)
plt.show()
Phys.Org News Partner Science news on Phys.org
Internet co-creator Cerf debunks 'myth' that US runs it
Astronomical forensics uncover planetary disks in Hubble archive
Solar-powered two-seat Sunseeker airplane has progress report
gsal
gsal is offline
#2
Nov21-12, 02:10 PM
P: 838
I don't follow...what is it that you are trying to achieve? Can you show a picture? If I uncomment the scatter plot and comment out the colormesh, I do see a nice picture...it is just that colormesh covers the entire place....are you sure you want colormesh? or some other function? how about bar?
funcosed
funcosed is offline
#3
Nov21-12, 03:57 PM
P: 36
Hi,
I've attached a link to a picture showing what I need, and I did try bar but couldnt get that to work properly either.

gsal
gsal is offline
#4
Nov21-12, 08:43 PM
P: 838

Python, matplotlib plot 2D histogram on polar axis.


Hhhhhmmm....maybe you just need to play around with the parameters of the mesh, you know, the colormap and which color correspond to which range...you should inspect the data you are plotting, maybe is too one sided or something
funcosed
funcosed is offline
#5
Nov22-12, 08:43 AM
P: 36
solution here :)


Register to reply

Related Discussions
best way to achieve a plot of polar coordinate points for CIE L*C*H* colour system Math & Science Software 0
Plotting CfA1 and CfA2 in polar coordinates using Python Astrophysics 0
Plot Polar Vector field Math & Science Software 0
Labelling the axis on a Maple plot Math & Science Software 0
polar axis? General Math 1