Python Windrose legend bracket format and loc


Below I have plotted a wind rose using Windrose based on <a href="https://www.google.co.uk/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwjuz72Gh9jPAhUmLMAKHWZxCuwQFggcMAA&url=https%3A%2F%2Fpypi.python.org%2Fpypi%2Fwindrose%2F&usg=AFQjCNGHVhwNYp_f2VtyGfBtsA61zp0duw" rel="nofollow">this</a>. Firstly, the legend is covering part of the rose but when I try to use loc to set it's location the legend disappears.

Secondly, the legend closing brackets are wrong i.e. [0.0 : 1.0[ any idea how I fix this to [0.0 : 1.0]

<a href="https://i.stack.imgur.com/pDf6i.png" rel="nofollow"><img alt="legend open bracket in place of close" class="b-lazy" data-src="https://i.stack.imgur.com/pDf6i.png" data-original="https://i.stack.imgur.com/pDf6i.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>


from windrose import WindroseAxes import matplotlib.cm as cm import matplotlib.pyplot as plt import numpy as np import pandas as pd df = pd.read_csv("C:\2007_GG_wind rose.csv") ws_SAR = df[' SARwind_10m'] wd_SAR = df['wind direction SAR model_int'] ws_mde = df['gg_mde'] wd_mde = df['wind direction MDE '] ax=WindroseAxes.from_ax() ax.bar(wd_SAR,ws_SAR,normed=True, opening=0.8, edgecolor='white') ax.set_legend() plt.title("SAR 10m U",y=1.08) #y=1.08 raises the title


Copy the original windrose.py from your python folder to your desired working directory. Name the copy somehow else, e.g. windrose_edit.py. Edit the file and look for the get_labels() function. I edited like this, but you can adopt it to your purpose.

def get_labels(): labels = np.copy(self._info['bins']) labels = ["%.1f : %0.1f" %(labels[i], labels[i+1]-0.1) \ for i in range(len(labels)-1)] return labels

also you can increase the fontsize of the legend some lines below.

def set_legend(self): l = self.legend(borderaxespad=-0.10) plt.setp(l.get_texts(), fontsize=12)

Finally import your edited file for example import windrose_edit as wind2

and use it with

winddir_ = yourdata windspeed_ = yourdata fig = plt.figure(figsize=(12, 8), dpi=100, facecolor='w', edgecolor='w') rect = [0.1, 0.1, 0.8, 0.8] ax = wind2.WindroseAxes(fig, rect, facecolor='w') ax.contourf(winddir_, windspeed_, bins=6, normed=True, cmap=cm.RdYlBu_r) ax.set_legend()

it's not beautiful although a relatively fast and lazy workaround


  • Error establish a database connection docker compose
  • Unable to connect to host MySQL database on application deployed to CloudBees
  • Flutter: How to read data from simple spreadsheet?
  • The Class-Path manifest attribute in [path] referenced one or more files that do not exist
  • Why should main be present in a Java class? [duplicate]
  • How to use application:get_env() in Erlang/OTP?
  • Debug vue-cli 3 generated app from Visual Studio Code
  • Redux Saga stopped by LOCATION_CHANGE too early
  • How do I replace custom “tags” in a string?
  • How to set file uploaded to server without .json extension to content type “application/json” using
  • The term 'add-migration' is not recognized as the name of a cmdlet
  • Selenium error - couldn't register this node: hub down or not responding
  • How to show data from array in windows 8 app
  • JOIN same table twice with aliases on SQLAlchemy
  • Incorrect product of two INT_MAX numbes in C/C++
  • Error Obtaining Lock (org.neo4j.kernal.StoreLockException)
  • pan gesture issue, slight movement within UIButton detection
  • Converting 900 MB .csv into ROOT (CERN) TTree
  • Lock file for access on windows
  • How to configure server to allow large file downloads?
  • error using selenium chromedriver on windows 7 64 bit
  • No session share and avoid navigation buttons in browser while opening application window
  • How to add a method to the versions model of Paper_trail?
  • Regular expression breakpoint in GDB
  • disable EJS caching in production
  • using php to create an xml file from a mysql db
  • Texture streaming in DirectX11, Immutable vs Dynamic
  • PHP users local time
  • MFMailComposer send email without presenting view
  • Angular FormGroup won't update it's value immediately after patchValue or setValue