Python Python, matplotlib plot 2D histogram on polar axis.

AI Thread Summary
The discussion revolves around a user seeking help with plotting a histogram on a polar axis using Python's Matplotlib. The user has three vectors: azimuth, frequency, and power, and is experiencing issues with the histogram display when using the `pcolormesh` function. They provide a code snippet that generates random data for these vectors and attempts to create a 2D histogram. While a scatter plot works correctly, the histogram appears problematic, covering the entire area instead of displaying the intended data. Other participants suggest exploring different plotting functions like `bar` and adjusting parameters such as colormap to improve the visualization. They also recommend inspecting the data to ensure it is not overly skewed, which could affect the histogram's appearance.
funcosed
Messages
35
Reaction score
0
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()
 
Technology news on Phys.org
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?
 
Hi,
I've attached a link to a picture showing what I need, and I did try bar but couldn't get that to work properly either.
 
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
 
solution here :)
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Replies
3
Views
1K
Replies
1
Views
2K
Replies
4
Views
3K
Replies
1
Views
1K
Replies
3
Views
3K
Replies
21
Views
5K
Replies
3
Views
3K
Back
Top