making columns of different sizes in Bokeh - python

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])
)

Related

Python Subplots Automate nrows and ncolumns

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

seaborn: limit the number of `col` in relplot()

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()

How do I combine dataframe (pandas) columns to plot confidence intervals in a Seaborn box plot?

My dataframe looks something like this:
I want to combine Column 1 and Column 2 by making a confidence interval (take the mean of Column 1 and Column 2, find the standard deviation, etc.) and then plot that using Seaborn box plots. Basically, I want to compare the values across the 4 rows (each row is an experimental subject) for each value (but each value has multiple measurements). In other words, I need to combine columns (replicate experiments) in the DataFrame. How would I go about doing this?
Here is what I'm hoping to get:
Thanks!

Creating a line graph for a top X in a dataframe (Pandas)

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)

Use the same column spacing as another QGridLayout with a different number of columns

I have a QGridLayout with 5 columns, and widgets with fixed widths are in columns 1 and 3, so that resizing the window will change the padding around them.
I would like to have another QGridLayout above that, but this time with 3 columns, where the 3rd one stretches to the end. I can't seem to get it to match the other layout though, and I'm wondering if there's anything I could do.
Here's an image of the box. The red arrows are the resizing width, and I'd like the green arrow to match those if possible. If I set the column stretch to 1|2 or 1|1|4 it resizes at the same rate, but is a bit far offset to the right.
I'm still learning Qt so it'd also be nice to know how how most people deal with issues like this.
You should nest the QGridLayout with 5 columns in another QGridLayout.
The first column will be empty, just like in the 3-column grid
The second column will have the labels for the first column of controls
The last column will contain the nested grid
That first column will contain the first row of controls (without labels)
The rest of that grid will be same as before
This way your controls should line up. If you want to line up the labels (take into account the right-alignment) you should use a column span of 2 on the outer grid

Categories

Resources