0

I have a large data set (growing number of x axis), the one shown at the bottom is enough to reproduce my case. I'm trying to plot this using Pandas and matplotlib. [I'm very new with python, so apologies in advance for any mistakes.]

import os
import sys
import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('test.csv', delimiter=',', index_col='Header')
df.plot(marker='s', figsize=(18,9))
plt.title("test")
plt.ylabel('y axis')
plt.xlabel('x axis')
plt.show()
sys.exit()

When I use the code above, it plots the graph, but I've got few issues.

  1. Y axis data points looks they have been scaled (which I did not ask)
  2. Missing few x axis data points, I understated it may not possible display all X axis values on the axis, which is fine. I was wondering would it be possible to display them on the actual data point when I move the mouse over them.

The latter is really crucial feature I'm after. My script is intended to track some data and when there is a visible bump in the plot, I need to be able to know which X values actually cause the bump. If anyone has suggestion for achieving the similar effect, they are much appreciated.

Header,header1,header2,header3,header4,header5,header6
x1,2115211,2223666,13332666,8448144,655564,366361
x2,2115213,2223666,13332666,8448144,655564,366361
x3,2115213,2223666,13332666,8448144,655564,366361
x4,2115213,2223666,13332666,8448144,655564,366361
x5,2115262,2229973,13330187,8448756,655523,366379
x6,2115262,2229973,13330187,8448756,655523,366379
x7,2115262,2229973,13330187,8448756,655523,366379
x8,2115277,2228613,13335478,8448221,655556,366362
x9,2115277,2228613,13335478,8448221,655556,366362
x10,2115211,2223666,13332666,8448144,655564,366361
x11,2115213,2223666,13332666,8448144,655564,366361
x12,2115213,2223666,13332666,8448144,655564,366361
x13,2115213,2223666,13332666,8448144,655564,366361
x14,2115213,2223666,13332666,8448144,655564,366361
x15,2115262,2229973,13330187,8448756,655523,366379
x16,2115262,2229973,13330187,8448756,655523,366379
x17,2115262,2229973,13330187,8448756,655523,366379
x18,2115277,2228613,13335478,8448221,655556,366362
x19,2115277,2228613,13335478,8448221,655556,366362

Any help is much appreciated.

Isuru H
  • 1,191
  • 1
  • 8
  • 11
  • 2
    For your second request, I don't think matplotlib alone can do it. You need to pair it with [mpld3](https://mpld3.github.io/) or just use [plotly](https://plot.ly/python/). – SSC Feb 06 '17 at 09:08
  • 1
    Of course matplotlib "can do it", see [here](http://stackoverflow.com/questions/19769262/getting-x-y-from-a-scatter-plot-with-multiple-datasets), [here](http://stackoverflow.com/questions/32945959/python-matplotlib-scatter-plot-change-color-on-the-clicked-point), and [here](http://stackoverflow.com/questions/7908636/possible-to-make-labels-appear-when-hovering-over-a-point-in-matplotlib). If you need help with implementing that, ask a more specific question about it. Concerning the first point "looks they have been scaled" is not a sufficient problem description. – ImportanceOfBeingErnest Feb 06 '17 at 20:00

0 Answers0