Created
July 6, 2014 02:27
-
-
Save MiyamonY/91e5a4cea131274a546d to your computer and use it in GitHub Desktop.
ipython と matplotlib
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
# In[26]: | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.dates as mdates | |
from datetime import datetime | |
from __future__ import print_function | |
# In[27]: | |
def conv_iso_date_str(s): | |
return "{0[0]}-{0[1]:0>2}-{0[2]:0>2}".format(s.split('/')) | |
# In[28]: | |
# datetimeオブジェクトに変換して更に数値に変換 | |
conv_fun = lambda s : mdates.date2num(datetime.strptime(conv_iso_date_str(s), "%Y-%m-%d")) | |
# In[29]: | |
# print(conv_fun('2013/4/05')) | |
# In[58]: | |
f = np.genfromtxt("data.csv", skip_header=6, dtype="int, float", delimiter=',',names="date, temp", usecols=('date','temp'), converters={"date":conv_fun}) | |
# In[59]: | |
print(f) | |
# In[60]: | |
plt.plot_date(f['date'], f['temp'], fmt='g:') # greenのドットで表示 | |
plt.xlabel('year') | |
plt.ylabel('temparature') | |
plt.title("temparature from 1998/07/06 to 2014/07/06") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment