0

I have drawn the following graph in matplotlib:

enter image description here

What I want is to have the beginning and the ending numbers for each axis. Is that possible? I want to omit the intermediate values while keeping the lines. I've searched a lot but nothing was found.

What I want is as follows:

enter image description here

medi
  • 55
  • 10
  • What exactly are "the beginning and the ending numbers for each axis"? Can you please explain clearly how you want your plot to look like? – ImportanceOfBeingErnest Mar 24 '18 at 11:09
  • @ImportanceOfBeingErnest I updated. – medi Mar 24 '18 at 11:16
  • What would be the criterion for the 0 being where it is (i.e. not at the edge) but the 240 being at the edge of the plot? In general you may position the labels whereever you want, using `ax.set_xticks([0,240])`, so it would be good to know what premisses you have here. – ImportanceOfBeingErnest Mar 24 '18 at 11:20
  • @ImportanceOfBeingErnest actually It continues and 240 is not the edge, I've cropped the image. My problem is that I have limited space and can not put all the intermediate values, because they overlap. Now, I want to put the limits to avoid that problem. – medi Mar 24 '18 at 11:26
  • In general, please provide a [mcve] of the issue. I.e. show a runnable version of code that produces the undesired behaviour, then clearly explain how you want the output to look like instead. Did you google for "setting limits in matplotlib" or similar? What is the actual problem here? – ImportanceOfBeingErnest Mar 24 '18 at 11:28
  • @ImportanceOfBeingErnest I've added the second image, that is exactly what I need. Isn't that representative? Moreover, the reason I couldn't add the entire graph is that I have to publish that, before publishing I'm not allowed to release the details. :) Moreover it is so large, it can not be added here. more than 10 million records. – medi Mar 24 '18 at 11:31
  • @ImportanceOfBeingErnest About the last part of your comment, yes, actually I've not found anything yet. – medi Mar 24 '18 at 11:36
  • Of course a [mcve] should not contain any actual data (noone wants to work with your actual data anyways), but just some numbers. Why not start with [an example](https://matplotlib.org/examples/pylab_examples/pythonic_matplotlib.html) from the matplotlib page and tell in how far you're not able to produce the desired plot? Is this problem about the horizontal size of the plot? – ImportanceOfBeingErnest Mar 24 '18 at 11:47
  • Look up “xticks” in the matplotlib documentation. –  Mar 24 '18 at 11:51
  • @ImportanceOfBeingErnest I've been coding for years. My code works properly. The point is that I don't know how, even you may not find anything. Actually that is a behavior that I don't know is supported or not. In third party UIs like telerik I've seen this behavior, but now I need this here. Take a look at [here](https://stackoverflow.com/a/26654656/5120235). That's the horizontal axis. My problem occurs in the vertical axis. – medi Mar 24 '18 at 11:52
  • The problem is that I do not understand your problem. This usually happens when people ask a question on how to do something with code without actually showing the code that produces the problem. It may well be that your problem can easily be solved with setting the xticks or xlims but one cannot know from the question. – ImportanceOfBeingErnest Mar 24 '18 at 11:59
  • @ImportanceOfBeingErnest doesn't the second image show what I want? my code is just plt.plot() – medi Mar 24 '18 at 12:01
  • Yes, and as I see it you get that with `ax.set_xticks([0,240])`. – ImportanceOfBeingErnest Mar 24 '18 at 12:04
  • @ImportanceOfBeingErnest Oh, boy :D thanks ALOT :D why didn't you say that at first :P Python is not my native framework, it's a bit strange ! – medi Mar 24 '18 at 12:17
  • 2
    I did say it in my second comment already. – ImportanceOfBeingErnest Mar 24 '18 at 12:21
  • I will just close it as duplicate then, since there is no need to have several answers to similar problems around. – ImportanceOfBeingErnest Mar 24 '18 at 12:30

0 Answers0