I have created a bar graph using a dataframe. The x-axis has duplicate values but it is not showing. I have provided the code, dataframe and bar graph below
car_sales.plot(x="Make", y="Odometer (KM)", kind="bar");
Bar graph
Dataframe
Related
got this data frame which i want to make into a stacked bar chart with the columns on the x axis
enter image description here
tried using barplot but just recive error 'height' must be a vector or a matrix
tried using ggplot(dataframe) and just returns grey rectangle
I created a graph object bar chart that has two different y-axes so that I can chart two different of different units for each category. However, now I'd like to add two horizontal lines. They won't be using values from the same y-axis though.
fig = go.Figure(
data=[
go.Bar(name='Bar 1',
x=category_x,
y=measure_1,
yaxis='y',
offsetgroup=1),
go.Bar(name='Bar 2',
x=category_x,
y=measure_2,
yaxis='y2',
offsetgroup=2)
]
)
Things look fine up to here.
Now, I'd like to add one horizontal line based off values from the first y-axis and another horizontal line based off values from the second y-axis. I tried using fig.add_hline() for this, but then both horizontal lines are displayed using values from the first y-axis. What should I be doing instead?
i have a shiny appp created which plots metagenome data using ggplot2, phyloseq and plotly with dplyr and tidyr. It creates pretty good stacked barplots and heatmaps only problem is it reorders sample names at x-axis e.g. 1-10 are arranged as 1,10,2,,5,6... how to correct that bug?
I have multiple ytraces data in an xarray array.
data trace selection can be done by
t=s_xr_all.sel(trace_index=slice(0,2,1),xy='y')
# trace_index and xy are dimension names and above selects subset of 3 traces (lines) into t
t.name='t'
t.hvplot.line(x='point_index',y='t')
The above creates a line plot with a widget slider that allows scrolling through the lines with single line displayed at a time
I would like to be able to plot all lines without creating the slider widget.hvplot documentation is sparse as to how to do that
t.hvplot.line(x='point_index',y='t').overlay()
The .overlay() function chaining eliminates the slider creation and all the lines in the xarray are displayed
I will make a stacked bar chart in matplotlib. Somehow it doesnt include all the bar chart that i gave him (there should be like 50 bar charts stacked on each other)
The code:
N=45 #numbers of columns
max_el=50
ind=np.arrange(N)
for bar in range(0,max_el):
y=[dic[value][bar] for value in dic]
plt.bar(ind,y,)
plt.show()
note: I used the similar code and same data and made a stacked bar chart with plotly (which worked)
With plotly
With matplotlib
Some of the values of variables are zeros or 0.1. Could that be the problem ?
As described in the comments, you need to add a bottoms array that keeps track of how much each should be moved up from the 0 line. Otherwise, they all start plotting a 0 and overplot one another, with the tallest one sticking up to its values and each one hiding those that were plotted before.