Trying to Plot this Raw JSON data into graph, doesn't want to have a individual graph for each entity/LDEV value ( will be difficult to compare). For Example : I wanted to create a graph with multiple line plot for LDEV_NUMBER - 00:42:26 , with X-axis value as Record time and Y- Axis value as "READ_IO_COUNT", Similarly, next line graph will represent next LDEV and so on.
import io
import pandas as pd
from pathlib import Path
import matplotlib.pyplot as plt
data = b'RECORD_TIME,LDEV_NUMBER,READ_IO_COUNT,WRITE_IO_COUNT,READ_MBYTES,WRITE_MBYTES,READ_RESPONSE_RATE,WRITE_RESPONSE_RATE,TOTAL_RESPONSE_RATE\r\ntime_t,string(16),ulong,ulong,ulong,ulong,float,float,float\r\n2020-03-16 00:00:42,"00:42:26",217,0,1,0,9.200517E+01,0.000000E+00,9.200517E+01\r\n2020-03-16 00:01:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:02:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:03:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:04:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:05:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:06:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:07:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:08:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:09:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:10:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:11:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:12:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:13:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:14:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:15:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:16:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:17:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:18:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:19:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:20:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:21:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:22:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:23:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:24:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:25:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:26:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:27:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:28:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:29:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:30:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:31:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:32:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:33:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:34:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:35:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:36:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:37:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:38:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:39:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:40:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:41:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:42:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:43:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:44:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:45:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:46:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:47:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:48:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:49:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:50:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:51:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:52:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:53:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:54:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:55:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:56:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:57:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:58:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:59:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:00:33,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:01:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:02:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:03:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:04:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:05:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:06:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:07:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:08:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:09:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:10:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:11:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:12:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:13:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:14:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:15:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:16:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:17:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:18:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:19:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:20:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:21:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:22:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:23:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:24:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:25:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:26:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:27:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:28:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:29:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:30:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:31:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:32:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:33:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:34:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:35:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:36:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:37:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:38:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:39:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:40:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:41:02,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:42:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:43:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:44:01,"00:42:26",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:55:02,"00:42:28",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:56:02,"00:42:28",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:57:01,"00:42:28",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:58:01,"00:42:28",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:59:02,"00:42:28",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 02:00:33,"00:42:28",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:17:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:18:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:19:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:20:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:21:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:22:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:23:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:24:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:25:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:26:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:27:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:28:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:29:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:30:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:31:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:32:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:33:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:34:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:35:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:36:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:37:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:38:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:39:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:40:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:41:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:42:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:43:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:44:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:45:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:46:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:47:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:48:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:49:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:50:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:51:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:52:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:53:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:54:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:55:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:56:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:57:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:58:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 00:59:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:00:33,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:01:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:02:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:03:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:04:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:05:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:06:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:07:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:08:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:09:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:10:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:11:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:12:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:13:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:14:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:15:01,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:16:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:17:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:18:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 01:59:02,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n2020-03-16 02:00:33,"00:42:2B",0,0,0,0,0.000000E+00,0.000000E+00,0.000000E+00\r\n\r\n'
df = pd.read_csv(io.StringIO(data.decode('ascii')))
df1=df.drop(df.index[0])
Lun_name=["00:42:2A","00:42:2B","00:42:27","00:42:26","00:42:28","00:42:29"]
for i in range(len(Lun_name)):
plt.plot(df.loc[df['LDEV_NUMBER'] =='%s'%Lun_name[i]]['RECORD_TIME'], df.loc[df['LDEV_NUMBER'] == '%s'%Lun_name[i]]['READ_IO_COUNT'])
plt.show()
Axes values are disoriented when i try to plot this using above code.
[READ IOPS]
with help of my colleague , i resolved it.Issue here is Y- Axis plotting data value are (for Ex: TOTAL_MBYTES ) with datatype as object , after converting it to integer, the axes looks fine . We did a slight modifications to the code as below
for i in range(len(portname)):
# plt.plot(df.loc[df['LDEV_NUMBER'] =='%s'%Lun_name[i]]['RECORD_TIME'], df.loc[df['LDEV_NUMBER'] == '%s'%Lun_name[i]]['READ_IO_COUNT'])
X = list(df1.loc[df1['PORT_NAME'] == '%s' % portname[i]]['DATETIME'])
Y = list(df1.loc[df1['PORT_NAME'] == '%s' % portname[i]]['TOTAL_MBYTES'])
ax = plt.axes()
ax.xaxis.set_minor_locator(dates.HourLocator(interval=4)) # every 4 hours
ax.xaxis.set_minor_formatter(dates.DateFormatter('%H:%M')) # hours and minutes
ax.xaxis.set_major_locator(dates.DayLocator(interval=1)) # every day
ax.xaxis.set_major_formatter(dates.DateFormatter('\n%d-%m-%Y'))
for i in range(len(Y)):
Y[i] = int(Y[i])
plt.plot(X, Y)
plt.ylabel('Processor throughput')
plt.xlabel('Time')
plt.legend(portname)
plt.savefig('port_throughput.png')
I have a script for plotting astronomical data of redmapping clusters using a csv file. I could get the data points in it and want to plot them using different colors depending on their redshift values: I am binning the dataset into 3 bins (0.1-0.2, 0.2-0.25, 0.25,0.31) based on the redshift.
The problem arises with my code after I distinguish to what bin the datapoint belongs: I want to have 3 labels in the legend corresponding to red, green and blue data points, but this is not happening and I don't know why. I am using plot() instead of scatter() as I also had to do the best fit from the data in the same figure. So everything needs to be in 1 figure.
import numpy as np
import matplotlib.pyplot as py
import csv
z = open("Sheet4CSV.csv","rU")
data = csv.reader(z)
x = []
y = []
ylow = []
yupp = []
xlow = []
xupp = []
redshift = []
for r in data:
x.append(float(r[2]))
y.append(float(r[5]))
xlow.append(float(r[3]))
xupp.append(float(r[4]))
ylow.append(float(r[6]))
yupp.append(float(r[7]))
redshift.append(float(r[1]))
from operator import sub
xerr_l = map(sub,x,xlow)
xerr_u = map(sub,xupp,x)
yerr_l = map(sub,y,ylow)
yerr_u = map(sub,yupp,y)
py.xlabel("$Original\ Tx\ XCS\ pipeline\ Tx\ keV$")
py.ylabel("$Iterative\ Tx\ pipeline\ keV$")
py.xlim(0,12)
py.ylim(0,12)
py.title("Redmapper Clusters comparison of Tx pipelines")
ax1 = py.subplot(111)
##Problem starts here after the previous line##
for p in redshift:
for i in xrange(84):
p=redshift[i]
if 0.1<=p<0.2:
ax1.plot(x[i],y[i],color="b", marker='.', linestyle = " ")#, label = "$z < 0.2$")
exit
if 0.2<=p<0.25:
ax1.plot(x[i],y[i],color="g", marker='.', linestyle = " ")#, label="$0.2 \leq z < 0.25$")
exit
if 0.25<=p<=0.3:
ax1.plot(x[i],y[i],color="r", marker='.', linestyle = " ")#, label="$z \geq 0.25$")
exit
##There seems nothing wrong after this point##
py.errorbar(x,y,yerr=[yerr_l,yerr_u],xerr=[xerr_l,xerr_u], fmt= " ",ecolor='magenta', label="Error bars")
cof = np.polyfit(x,y,1)
p = np.poly1d(cof)
l = np.linspace(0,12,100)
py.plot(l,p(l),"black",label="Best fit")
py.plot([0,15],[0,15],"black", linestyle="dotted", linewidth=2.0, label="line $y=x$")
py.grid()
box = ax1.get_position()
ax1.set_position([box.x1,box.y1,box.width, box.height])
py.legend(loc='center left',bbox_to_anchor=(1,0.5))
py.show()
In the 1st 'for' loop, I have indexed every value 'p' in the list 'redshift' so that bins can be created using 'if' statement. But if I add the labels that are hashed out against each py.plot() inside the 'if' statements, each data point 'i' that gets plotted in the figure as an intersection of (x[i],y[i]) takes the label and my entire legend attains in total 87 labels (including the 3 mentioned in the code at other places)!!!!!!
I essentially need 1 label for each bin...
Please tell me what needs to done after the bins are created and py.plot() commands used...Thanks in advance :-)
Sorry I cannot post my image here due to low reputation!
The data 'appended' for x, y and redshift lists from the csv file are as follows:
x=[5.031,10.599,10.589,8.548,9.089,8.675,3.588,1.244,3.023,8.632,8.953,7.603,7.513,2.917,7.344,7.106,3.889,7.287,3.367,6.839,2.801,2.316,1.328,6.31,6.19,6.329,6.025,5.629,6.123,5.892,5.438,4.398,4.542,4.624,4.501,4.504,5.033,5.068,4.197,2.854,4.784,2.158,4.054,3.124,3.961,4.42,3.853,3.658,1.858,4.537,2.072,3.573,3.041,5.837,3.652,3.209,2.742,2.732,1.312,3.635,2.69,3.32,2.488,2.996,2.269,1.701,3.935,2.015,0.798,2.212,1.672,1.925,3.21,1.979,1.794,2.624,2.027,3.66,1.073,1.007,1.57,0.854,0.619,0.547]
y=[5.255,10.897,11.045,9.125,9.387,17.719,4.025,1.389,4.152,8.703,9.051,8.02,7.774,3.139,7.543,7.224,4.155,7.416,3.905,6.868,2.909,2.658,1.651,6.454,6.252,6.541,6.152,5.647,6.285,6.079,5.489,4.541,4.634,8.851,4.554,4.555,5.559,5.144,5.311,5.839,5.364,3.18,4.352,3.379,4.059,4.575,3.914,5.736,2.304,4.68,3.187,3.756,3.419,9.118,4.595,3.346,3.603,6.313,1.816,4.34,2.732,4.978,2.719,3.761,2.623,2.1,4.956,2.316,4.231,2.831,1.954,2.248,6.573,2.276,2.627,3.85,3.545,25.405,3.996,1.347,1.679,1.435,0.759,0.677]
redshift = [0.12,0.25,0.23,0.23,0.27,0.26,0.12,0.27,0.17,0.18,0.17,0.3,0.23,0.1,0.23,0.29,0.29,0.12,0.13,0.26,0.11,0.24,0.13,0.21,0.17,0.2,0.3,0.29,0.23,0.27,0.25,0.21,0.11,0.15,0.1,0.26,0.23,0.12,0.23,0.26,0.2,0.17,0.22,0.26,0.25,0.12,0.19,0.24,0.18,0.15,0.27,0.14,0.14,0.29,0.29,0.26,0.15,0.29,0.24,0.24,0.23,0.26,0.29,0.22,0.13,0.18,0.24,0.14,0.24,0.24,0.17,0.26,0.29,0.11,0.14,0.26,0.28,0.26,0.28,0.27,0.23,0.26,0.23,0.19]
Working with numerical data like this, you should really consider using a numerical library, like numpy.
The problem in your code arises from processing each record (a coordinate (x,y) and the corresponding value redshift) one at a time. You are calling plot for each point, thereby creating legends for each of those 84 datapoints. You should consider your "bins" as groups of data that belong to the same dataset and process them as such. You could use "logical masks" to distinguish between your "bins", as shown below.
It's also not clear why you call exit after each plotting action.
import numpy as np
import matplotlib.pyplot as plt
x = np.array([5.031,10.599,10.589,8.548,9.089,8.675,3.588,1.244,3.023,8.632,8.953,7.603,7.513,2.917,7.344,7.106,3.889,7.287,3.367,6.839,2.801,2.316,1.328,6.31,6.19,6.329,6.025,5.629,6.123,5.892,5.438,4.398,4.542,4.624,4.501,4.504,5.033,5.068,4.197,2.854,4.784,2.158,4.054,3.124,3.961,4.42,3.853,3.658,1.858,4.537,2.072,3.573,3.041,5.837,3.652,3.209,2.742,2.732,1.312,3.635,2.69,3.32,2.488,2.996,2.269,1.701,3.935,2.015,0.798,2.212,1.672,1.925,3.21,1.979,1.794,2.624,2.027,3.66,1.073,1.007,1.57,0.854,0.619,0.547])
y = np.array([5.255,10.897,11.045,9.125,9.387,17.719,4.025,1.389,4.152,8.703,9.051,8.02,7.774,3.139,7.543,7.224,4.155,7.416,3.905,6.868,2.909,2.658,1.651,6.454,6.252,6.541,6.152,5.647,6.285,6.079,5.489,4.541,4.634,8.851,4.554,4.555,5.559,5.144,5.311,5.839,5.364,3.18,4.352,3.379,4.059,4.575,3.914,5.736,2.304,4.68,3.187,3.756,3.419,9.118,4.595,3.346,3.603,6.313,1.816,4.34,2.732,4.978,2.719,3.761,2.623,2.1,4.956,2.316,4.231,2.831,1.954,2.248,6.573,2.276,2.627,3.85,3.545,25.405,3.996,1.347,1.679,1.435,0.759,0.677])
redshift = np.array([0.12,0.25,0.23,0.23,0.27,0.26,0.12,0.27,0.17,0.18,0.17,0.3,0.23,0.1,0.23,0.29,0.29,0.12,0.13,0.26,0.11,0.24,0.13,0.21,0.17,0.2,0.3,0.29,0.23,0.27,0.25,0.21,0.11,0.15,0.1,0.26,0.23,0.12,0.23,0.26,0.2,0.17,0.22,0.26,0.25,0.12,0.19,0.24,0.18,0.15,0.27,0.14,0.14,0.29,0.29,0.26,0.15,0.29,0.24,0.24,0.23,0.26,0.29,0.22,0.13,0.18,0.24,0.14,0.24,0.24,0.17,0.26,0.29,0.11,0.14,0.26,0.28,0.26,0.28,0.27,0.23,0.26,0.23,0.19])
bin3 = 0.25 <= redshift
bin2 = np.logical_and(0.2 <= redshift, redshift < 0.25)
bin1 = np.logical_and(0.1 <= redshift, redshift < 0.2)
plt.ion()
labels = ("$z < 0.2$", "$0.2 \leq z < 0.25$", "$z \geq 0.25$")
colors = ('r', 'g', 'b')
for bin, label, co in zip( (bin1, bin2, bin3), labels, colors):
plt.plot(x[bin], y[bin], color=co, ls='none', marker='o', label=label)
plt.legend()
plt.show()