Search code examples
pythonmatplotlibgraph

Making a scrictly increasing graph into a sinus rhythm sort of graph


Right now I have a graph of this sort: enter image description here

But I want to make the above graph into something like this:

enter image description here

Can anyone guide me how to do this using Matplotlib?


Solution

  • try plotting the first difference of your time series such as:

    # sample data (this is your "before" data):
    df = pd.DataFrame({'data you are plotting now': [1, 2, 3, 4]})
    
    # new data to plot:
    df['new data'] = df['data you are plotting now'] - df['data you are plotting now'].shift()
    

    assuming data['data you are plotting now'] is your current time series

    I should add that generally you should add your code and your input data as well as your expected output data and not images.