How to plot column chart with bars for 2 categories next to each other? - pandas

I need to draw chart like this one. I have 2 categories, named 0 and 1. I want to plot "age vs amount" etc with 2 categories compared next to each other.
df.groupby(by = df['target']).plot(kind='bar')
but it draws 2 separate charts.

https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.plot.bar.html
You can find the sub-plot documentation here for making a bar chart like your requirement

Related

Plotting bar plots for categorical variables in STATA

I have a survey data baseline and endline. I am trying to plot bar plot for qualification of the respondent in each group (baseline/endline).
I am using the following code:
graph bar, over(qualification) over(time)
It is giving me different output from what I want.
I want the bars for endline and baseline for each category to be present parallel.
I am also attaching a reference picture to get the better idea about what I want.
The order of the over options of graph bar matters.
Consider this example:
clear
input x str1 a b
1 "a" 1
2 "a" 2
3 "b" 1
4 "b" 2
end
graph bar x, over(a) over(b) title("over(a) over(b)")
graph bar x, over(b) over(a) title("over(b) over(a)")
It looks like you need to swap the order of your over options.

Migradoc - aligning a table vertically

I would like to position my table by controlling its placement both vertically and horizontally.
I can place it horizontally using the following:
Commodtable.Rows.LeftIndent = "5cm"
How do I do the same but vertically? I know there is verticalalignment but there are only 3 options: Top, Middle and bottom.
This is so i can eventually place 6 tables in a 3 x 2 arrangement.
To get the 3 x 2 arrangement you can add tables to a table.
See this post:
https://stackoverflow.com/a/36304148/162529
Do draw a table at an absolute position you can add the table to a TextFrame object.
But to get the 3 x 2 arrangement, I would probably prefer nested tables.

Plotting count in Excel

My data is like :
Portfolio Type of Assets Count
Portfolio 1 Type A 10
Type B 5
Type C 7
Portfolio 2 Type A 5
Type B 10
I am trying to plot a Bar graph where the each bar will have Portfolio 1 or similar on x-axis, the count of assets on the bar representing different colors and labels of colors like Red area in a bar represents the Type A assets. How can I plot that, I have tried this for a very long time, but not able to get it. Can anyone throw some hint please?
Click here and watch a YouTude, you will discover select data.

Getting a series in a chart to have different colours for each series item

I have 10 items:
Col1, Col2
One, 1
Two, 7
Three, 45
Four, 2
etc...
By default each series is one colour, so each bar in the chart is the same colour. I would like each bar to have a different colour or gradient.
I can do it by switching the labels to be at the side, but I would like the labels of the series to be on the bottom.
Select a data point (a bar),
Right click > Format Data Point > Fill > Select vary colours by point.
It adds a legend to the right, but you can remove that if you want.

GNUPLOT: dot plot with data depending dot size

I am trying plot data sets consisting of 3 coordinates:
X-coordinate, x-coordinate and the number of occurrences.
example:
1 2 10
3 1 2
3 2 1
I would like to draw for every line a dot at x,y with a diameter which is depending on the third value.
Is that possible with Gnuplot?
Create a 2D plot with variable point size. See the demo.
Example:
plot 'dataFile.dat' u 1:2:3 w points lt 1 pt 10 ps variable
This is basically equivalent to the existing answer, just shorter:
plot 'dataFile.dat' with circles
Credit: Gnuplot: plot with circles of a defined radius