0

I was doing some analysis and then I want to plot the data, everything is ok, no errors - but I want to ask how I can add to my code a setting, which extends x-axis, thus I can see all numbers from 0 to 115 (now I can only guess if the dot very below is 17th or 18th)

This is the line from my complex code, where I plot my data from PCA using matplotlib (here I am plotting the 1st pca):

plt.plot(data [:, 0], "-o", )

and here is my graph

  • You can enable the grid, or zoom in. What result are you expecting, exactly? – Mad Physicist Dec 05 '19 at 14:09
  • I would like to have written al numbers at x-axis, as "1,2,3,4,5,...." and then I could indetify the dots very below, because now I cant be sure which "number" at x-axis are they – HungryMolecule Dec 05 '19 at 14:14
  • 1
    You could enable the minor ticks and the grid to see better, by using `ax = plt.gca()` `ax.grid(True, "both", "x")`. – Guimoute Dec 05 '19 at 14:30
  • 1
    If you label each datapoint it would look [like this](https://i.stack.imgur.com/5RTjc.png). Since this is of course not what you want, please be clear about the expected result. See first comment. – ImportanceOfBeingErnest Dec 05 '19 at 14:33
  • Ok, if it would look like that (definitely not what I want it to look like) - then I would also need extend the x-axis, right? to be able to read numbers at x-axis – HungryMolecule Dec 05 '19 at 15:06
  • Please use something like paint or Photoshop to draw what you want to do – Mad Physicist Dec 05 '19 at 15:16
  • Maybe you want to look at [make labels appear when hovering over a point](https://stackoverflow.com/questions/7908636/possible-to-make-labels-appear-when-hovering-over-a-point-in-matplotlib) or maybe [get data from plot](https://stackoverflow.com/questions/13306519/get-data-from-plot-with-matplotlib) – gboffi Dec 05 '19 at 15:42
  • Do you use an interactive backend (i.e., you have a window that appears on the screen, containing the graph) or you plot directly to a file and later use an image/document viewer to inspect your plot? In the first case it is possible to interact with the graph, especially zooming and panning into it --- when you zoom in, also the labels in the axes are adjusted accordingly and you can clearly see the abscissa of any particular point... – gboffi Dec 05 '19 at 15:51
  • You can make your figure bigger, but to make 115 ticks all show up and not overlap (assuming a font size of 10 pts), you'd need to make the figure about 47 inches wide. – Jody Klymak Dec 05 '19 at 17:10

0 Answers0