python - Box Plot Trellis -
I have some data. Let's say it's weather data, for this example of rain and temperature for every month , I will generate randomly like this:
def rand_weather (n): month = n% 12 + 1 temp_ind = np.random.randint (0,4) temp = ["freezing "," Winter "," moderate "," hot "," extreme "] [temp_ind] rain = np.random.normal (50 - 4 * temp_ind, 25) + np.random.randint (020) Return month , Rain, temporary data = [RAND_WEDER (N) in the range N (3000)] rain_record = pd.DataFrame (data, column = ["month", "rain", " Then the data looks like this: month precipitation temporary 0 1 78.364133 freezing 1 2 54.2 9 022 cold 2 3 81.341265 cold 3 4 98.980334 Hot ......... .. 12 1 66.378066 Medium 13 2 44.264323 Medium ... ... ... ...
I have to make a chart.
I can draw a trail chart of such tools:
avgs = rain_record.groupby (['temp', ' Month ']) Meaning () Avgs.reset_index (inplac e = True) #' Temporary 'and' Month 'columns again import pandas. Tools. Rplot plt.figure (fig = (12,6), dpi = 20) as apllot, plt.title = pattern plot = rplot.rplot (avgs, y = 'rain', x = 'month') plot.add ( Rplot.TrellisGrid (['temp', '.'])) Plot.add (rplot.GomScatter ()) # plot.add (rplot .GeomPoint (size = 80.0, alpha = 0.5)) T = plot. Render (plt.gcf ())
and I can attract a box plot of each 'temp'
to do this ('for cold'):
< Code> rain_record [rain_record.temp == 'cool']. Boxplot (= 'month')
I could loop any temporarily arising as one of those series. But the axis will not be raised internally, as if it is in the trailis, I think the option is available in the Manolely setup maplelibes axis, but I am not a good way to do this.
You can use, especially factorplot
function:
Import seaborne as SES SSSSSstyle ("WhiteGrid"). "Rain", line = "temporary", data = rain_record, size = 2, aspect = 5, type = "box", palette = "pushbug_d") sns.despine (left = true)
Comments
Post a Comment