Make a wind rose chart with Plotly Express
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

I'd love to have a wind rose chart made with Plotly Express just like the one shown here. You can see a graph and the data here. This will involve some data manipulation to fill it in, and to convert the data from degrees to the same cardinal directions shown in the Plotly example. Please use the same buckets for data that the Plotly example has, not the ones in the graph and data.

Hello does it have to be a one shot graph ? or do you want to be able to give data to a script that generates the HTML file and all the conversions are done automatically ?
kerncy 4 months ago
It'd be great to have a Python script that contains the whole thing; so if you could share a gist that reads the data into a pandas df then creates the graph that'd be great. Thanks for clarifying.
msund 4 months ago
OK I see, Just to be sure that I'm in the right direction, here is a first manual transformation of the data that regroups (36) direction to (16) cardinal points, sum the regrouped values(for example E is the sum of direction 070-090, 080-100 and 090-110), and set them as a graph : is it something like that that you want ?
kerncy 4 months ago
Looks great yep.
msund 4 months ago
awarded to kerncy

Crowdsource coding tasks.

1 Solution

Winning solution


Here is my solution, it can be download here :

To use it just run

python3 data.txt

data.txt is the raw data file as the one provided in your sample. I suppose that format will never change (regarding comments, separators, ...). It dynaminc in terms of number of lines in the file, only directions should always be kept as "begin-end". The number of Strenght is dynamic to. First line of data must be the headers representing the strenghts.

It will generate a wind_out.html file as output that will contain your graph.

I consider my "conversion" process a little hacky and I assume that it should be possible to be done in a better way using pandas dataframe instead of python array.

Process is the following :

  • read the file by converting the provided degrees to cardinality. Each cardinality represents a subset of degrees. If the mean deegrees (for exampe 030-050, mean is 40) of your line is inside the interval of the cardinal, than this line is associated to this cardinality
  • next step, is to merge frequencies that shares the same cardinal using sumElements function
  • final step, generate a json object that will be converted to a dataframe and visualized using plotly

Do not hesitate if you have any question

Hey there, thanks so much. I assume this works, sounds right. I'm the worst; is there any chance you could host this in Colab or a similar environment and make the graph for it? I don't have Python or anything set up on my work computer so can't really run it. It'd be great to be able to eyeball it. For example:
msund 4 months ago
Hi, I don't know how colab works. So I put the data into a project : In the file you can modifiy the "process" function to pass an input and output file. The HTML will be generated in the root directory of the project, you will then be able to download it. Is it ok for you ?
kerncy 4 months ago
Here is your colab link : In fact it was really simple to use. Just import your file, set the path in the process function and you will be able to run it and display the generated graph :)
kerncy 4 months ago