반응형
Recent Posts
Recent Comments
관리 메뉴

개발잡부

[matplotlib] line chart sample 1 본문

Python/matplotlib

[matplotlib] line chart sample 1

닉의네임 2022. 8. 19. 14:08
반응형


import matplotlib.pyplot as plt
from matplotlib.collections import EventCollection
import numpy as np

plt.rcParams['font.family'] = 'AppleGothic'

xdata= range(0, 88)
ydata1= [67.89, 15.56, 12.77, 13.39, 15.69, 13.18, 16.3, 13.92, 16.8, 14.18, 15.05, 28.49, 15.1, 14.96, 12.1, 13.23, 16.92, 13.55, 16.1, 14.2, 15.43, 12.78, 15.55, 12.78, 12.35, 15.06, 14.21, 15.68, 12.33, 14.07, 15.72, 17.83, 14.73, 15.15, 15.25, 17.16, 14.07, 15.78, 13.09, 16.08, 13.68, 16.5, 13.84, 18.75, 15.81, 13.72, 12.31, 16.27, 13.98, 15.77, 13.66, 16.07, 13.2, 19.21, 17.44, 14.59, 13.94, 13.15, 12.61, 15.28, 12.96, 15.59, 12.87, 17.43, 12.83, 13.27, 14.97, 12.9, 15.94, 14.06, 15.8, 15.65, 15.36, 13.38, 15.62, 13.18, 12.86, 14.95, 13.27, 11.63, 14.37, 11.99, 12.27, 15.38, 12.93, 16.86, 16.48, 19.36]
ydata2= [15.35, 14.86, 15.27, 12.97, 15.53, 12.2, 12.92, 14.8, 20.03, 12.12, 12.04, 11.95, 15.1, 12.89, 12.03, 14.99, 11.97, 16.91, 12.14, 17.73, 12.21, 12.0, 15.77, 11.25, 12.92, 15.79, 13.17, 12.03, 14.78, 12.25, 12.97, 14.99, 13.07, 12.95, 17.98, 12.02, 15.02, 14.98, 17.03, 11.93, 14.83, 12.24, 11.92, 15.8, 13.24, 12.94, 23.85, 16.22, 16.93, 16.87, 12.11, 12.98, 14.77, 13.21, 13.02, 15.07, 13.98, 14.69, 14.26, 15.8, 13.26, 16.76, 13.16, 16.82, 12.18, 11.97, 15.84, 13.17, 16.73, 15.25, 14.7, 12.26, 11.95, 15.83, 12.18, 12.06, 15.72, 16.3, 16.04, 11.93, 12.07, 15.1, 12.89, 11.98, 15.03, 12.96, 15.77, 13.24]

# plot the data
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
ax.plot(xdata, ydata1, color='tab:blue')
ax.plot(xdata, ydata2, color='tab:orange')
ax.set_ylabel('query 속도(ms)')
ax.set_xlabel('조회수(회)')

# create the events marking the x data points
xevents1 = EventCollection(xdata, color='tab:blue', linelength=0.05)
xevents2 = EventCollection(xdata, color='tab:orange', linelength=0.05)

# create the events marking the y data points
yevents1 = EventCollection(ydata1, color='tab:blue', linelength=0.05,
                           orientation='vertical')
yevents2 = EventCollection(ydata2, color='tab:orange', linelength=0.05,
                           orientation='vertical')

# add the events to the axis
ax.add_collection(xevents1)
ax.add_collection(xevents2)
ax.add_collection(yevents1)
ax.add_collection(yevents2)

# set the limits
ax.set_xlim([0, len(xdata)])
ax.set_ylim([0, 100])

ax.set_title('array aggs[BLUE] vs nested aggs[ORANGE]')

# display the plot
plt.show()

 

반응형

'Python > matplotlib' 카테고리의 다른 글

[matplotlib] pie chart sample 1  (0) 2022.08.19
[matplotlib] line chart sample 2  (0) 2022.08.19
[matplotlib] 한글깨짐  (0) 2022.01.18
[matplotlib] 선그래프 응용  (0) 2021.12.30
[matplotlib] 기본그래프2  (0) 2021.12.30
Comments