I am writing code that will output subplots for anything between 1 subplot and 20 subplots. The row and column configuration for all 20 different types of plots will be different, (e.g. for 4 subplots, I'll want 2 rows and 2 columns, but for 12 subplots I'll want 3 rows and 4 columns), and instead of typing in the number of rows and columns I want for each different number of subplots, I was wondering if there was a way to automatically generate the nrow and ncolumn values based off of the number of subplots I want in the image. I know there are similar questions to this out there, but I've only seen answers that suggest manually entering in the number of rows and columns you want for each subplot, and haven't seen a way to automate it yet. Thanks in advance for the help!
Maybe try the package grid_strategy? https://github.com/matplotlib/grid-strategy
Related
I have 18 individual of np.arrays, each containing 30 numbers with similar range (share = True).
I want to create boxplots for all 18 arrays in a subplot of 1 row, 4 columns. Each subplot will contain few sets of arrays.
How do I do this?
when I try it, it looks like this:
This was my trying to put them in one, the red scratch was what I want it to look like
I get this solved!!
Since it's only 1 row,
I should use only
-axes(num)
instead of
-axes(num,0)
If I specified col arg in relplot(), it will plot for each category in col column.
But if there were too many categories in col columns, the graph would be squeezed vertically, because seaborn will put all plots in one row.
I remembered that there is an argument to solve this problem: something like max_number_of_col=4, which puts 4 plots on each row so when the row is full, it will plot on next row.
Unfortunately, I'm not 100% sure whether this is an api of seaborn or not. Please, let me know any api which has this function.
You are looking for the col_wrap= argument to replot()
I'm trying to make a line graph for my dataframe that has the names of 10 customers on the X axis and their amount of purchases they made on the Y axis.
I have over 100 customers in my data frame, so I created a new data frame that is grouped by customers and which shows the sum of their orders and I wish to only display the top 10 customers on my graph.
I have tried using
TopCustomers.nlargest(10, 'Company', keep='first')
But I run into the error nlargest() got multiple values for argument 'keep' and if I don't use keep, I get told it's a required argument.
TopCustomers is composed of TopCustomers = raw.groupby(raw['Company'])['Orders'].sum()
Sorting is not required at the moment, but it'd be good to know in advance.
On an additional Note: The list of customer's name is rather lengthy and, after playing with some dummy data, I see that the labels for the X axis are stacked on top of each other, is there a way to make it bigger so that all 10 are clearly visible? and maybe mark a dot where the X,Y meets?
we can do sort_values and tail
TopCustomers.sort_values().tail(10)
I am new to Bokeh and am trying to make a layout of 3 columns which have different amount of plots. For example, column 1 has 3 plots, but column 2 has 4 plots. So far the only way I can do it is by padding the shorter columns with extra entries, but this is obviously a waste of space.
I saw in this example that is is possible to do w/ rows of different sizes, so I hope one can do so w/ columns...
It is possible to do this by composing your layout using the row and column methods from the layouts module. Here is an example of what that could look like:
from bokeh.layouts import row, column
my_layout = row(
column([plot1, plot2, plot3]),
column([plot4, plot5])
)
I have a DataFrame that looks like this:
spot total
date_delivery
2016-06-21 x 20
2016-07-25 x 22
2016-08-14 x 25
2016-09-11 y 16
2016-10-16 y 10
The index of the DataFrame is in a datetime format. I want to create a simple graph for each unique spot that shows the total over time. I am having trouble writing a loop that performs this as well as saves each one. Keep in mind that while there is only 2 actual spots in this DataFrame the real one has many many more.
Append spot to the index, groupby spot and then plot
df.set_index('spot', append=True).groupby(level='spot').plot(kind='bar')
For your example you'll get two bar graphs, one for x, one for y, right below each other (but you can customize that)