0

A similar question has been asked here. But it is concerned with the scatter plot. I want to achieve the same with simple line plot. I know there are solutions for drawing multicolored line but I'm not interested in that.

I want something like below where maxima and minima are clearly distinguishable by color:

Expection

In this stackoverflow answer provides a very close solution however it is not generic, it works on predefined functions, does not work on dataset.

In R it is doable using ggplot2 (Source)

Is there any way to achieve this?

tachyon
  • 361
  • 1
  • 9
  • 1
    What's wrong with scatter? If you really just don't like the name, you could always rename `plot=scatter`... – HAL 9001 Feb 16 '19 at 17:24
  • @HAL9001, I want continuous line, not just discrete points. – tachyon Feb 16 '19 at 17:26
  • Might be useful (and possible duplicates): https://stackoverflow.com/questions/13622909/matplotlib-how-to-colorize-a-large-number-of-line-segments-as-independent-gradi/13649811#13649811 https://stackoverflow.com/questions/16051270/matplotlib-plotting-a-single-line-that-continuously-changes-color – HAL 9001 Feb 16 '19 at 18:11
  • The question I marked as duplicate encodes `x` as color. I suppose it's obvious how to use `y` instead. – ImportanceOfBeingErnest Feb 16 '19 at 18:44

0 Answers0