【发布时间】:2011-05-26 21:51:52
【问题描述】:
我正在使用 matplotlib 散点图 Oracle 表中的一些数据。其中一个字段是 DATE,在以下查询中将其转换为 to_char 时出现错误。我想按 00-23 小时而不是按日期散布图。所以 Y 轴应该显示 00-23。请参阅下面的代码示例以及错误。
感谢您的帮助。
import cx_Oracle, os
import numpy
import matplotlib.pyplot as plt
这行得通
sql = """select number_of_small_reads, number_of_small_writes, number_of_large_reads, number_of_large_writes, end_time from schema.table order by end_time"""
这不起作用
sql = """select number_of_small_reads, number_of_small_writes, number_of_large_reads, number_of_large_writes, to_char(end_time, 'HH24') e from schema.table order by e"""
我收到以下错误: “不能使用灵活类型执行reduce”
conn = cx_Oracle.Connection("user/password@server:1521/database")
cursor = conn.cursor()
cursor.execute(sql)
rowset = cursor.fetchall()
cursor.close()
cx1 = []
cx2 = []
cx3 = []
cx4 = []
cy = []
cx1, cx2, cx3, cx4, cy = zip(*rowset)
ax = plt.figure().add_subplot(111)
ax.scatter(cx1, cy, s=9, c='b', marker='o', label='number_of_small_reads')
ax.scatter(cx2, cy, s=9, c='r', marker='o', label='number_of_small_writes')
ax.scatter(cx3, cy, s=9, c='g', marker='o', label='number_of_large_reads')
ax.scatter(cx4, cy, s=9, c='y', marker='o', label='number_of_large_writes')
plt.legend(shadow=True)
plt.title('Python Generated Chart')
plt.xlabel('IOPS')
plt.ylabel('By Date')
plt.xlim(0)
plt.show()
conn.close()
【问题讨论】:
标签: python oracle matplotlib