import
pandas as pd
from
matplotlib
import
pyplot as plt
data
=
pd.read_csv(r
"Downloads/cars1.csv"
)
data.head()
df
=
pd.DataFrame(data)
name
=
df[
'car'
].head(
12
)
price
=
df[
'price'
].head(
12
)
fig, ax
=
plt.subplots(figsize
=
(
16
,
9
))
ax.barh(name, price)
for
s
in
[
'top'
,
'bottom'
,
'left'
,
'right'
]:
ax.splines[s].set_visible(
False
)
ax.xaxis.set_ticks_position(
'none'
)
ax.yaxis.set_ticks_position(
'none'
)
ax.xaxis.set_tick_params(pad
=
5
)
ax.yaxis.set_tick_params(pad
=
10
)
ax.grid(b
=
True
, color
=
'grey'
,
linestyle
=
'-.'
, linewidth
=
0.5
,
alpha
=
0.2
)
ax.invert_yaxis()
for
i
in
ax.patches:
plt.text(i.get_width()
+
0.2
, i.get_y()
+
0.5
,
str
(
round
((i.get_width()),
2
)),
fontsize
=
10
, fontweight
=
'bold'
,
color
=
'grey'
)
ax.set_title(
'Sports car and their price in crore'
,
loc
=
'left'
, )
fig.text(
0.9
,
0.15
,
'Jeeteshgavande30'
, fontsize
=
12
,
color
=
'grey'
, ha
=
'right'
, va
=
'bottom'
,
alpha
=
0.7
)
plt.show()