4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

pandasのplotだけでy軸の範囲指定したグラフ表示

Posted at

PythonのpandasでCSVを読み込んでplotでグラフ化するにあたり、x軸の列指定とy軸の範囲指定を実施しました。
調べるとmatplotlibでplt.ylimみたいなのが多く出てきますが、plotだけで出来ました。

まずはCSVファイルを読み込みます。

import pandas as pd

df = pd.read_csv('stock_nasdaq_1.csv')
df

image.png

Unnamed: 0という余計な列をdropで削除します。

dfr=df.drop("Unnamed: 0", axis=1)
dfr

image.png

x軸にDateの列を指定してグラフ表示します。

dfr.plot(x='Date')

image.png

y軸の範囲を0〜20に指定してグラフを表示します。

dfr.plot(x='Date',ylim=[0,20])

image.png

4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?