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.
Related
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
I was looking for an answer everywhere, but I just couldn't find one to this problem (maybe I was just too stupid to use other answers, because I'm new to R).
I have two data frames with different numbers of rows. I want to create a plot containing a single bar per data frame. Both should have the same length and the count of different variables should be stacked over each other. For example: I want to compare the proportions of gender in those to data sets.
t1<-data.frame(cbind(c(1:6), factor(c(1,2,2,1,2,2))))
t2<-data.frame(cbind(c(1:4), factor(c(1,2,2,1))))
1 represents male, 2 represents female
I want to create two barplots next to each other that represent, that the proportions of gender in the first data frame is 2:4 and in the second one 2:2.
My attempt looked like this:
ggplot() + geom_bar(aes(1, t1$X2, position = "fill")) + geom_bar(aes(1, t2$X2, position = "fill"))
That leads to the error: "Error: stat_count() must not be used with a y aesthetic."
First I should merge the two dataframes. You need to add a variable that will identify the origin of the data, add in both dataframes a column with an ID (like t1 and t2). Keep in mind that your columnames are the same in both frames so you will be able to use the function rbind.
t1$data <- "t1"
t2$data <- "t2"
t <- (rbind(t1,t2))
Now you can make the plot:
ggplot(t[order(t$X2),], aes(data, X2, fill=factor(X2))) +
geom_bar(stat="identity", position="stack")
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.
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.
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