Python27 matplotlib: related first and last elements

Hi, I found the same problem, but no answer: enter the link here

My problem is that I am trying to build data using matplotlib and linking the first and last data points. I use python27 and Windows 7. My problem is just big to show the full, so I just show some parts of the source code. The graph function looks like this:

def plot(x, aw,temperature):
    plt.clf()
    temperatureplot = plt.subplot(211)
    awplot = plt.subplot(212)

    temperatureplot.grid()
    awplot.grid()  

    #set subplots
    awplot.set_ylabel('water activity aw')
    awplot.plot(x,aw)
    awplot.margins(y=0.05) #adds a gap between maximum value and edge of diagram
    temperatureplot.set_ylabel('Temperature in degree C')
    temperatureplot.plot(x,temperature)
    temperatureplot.margins(y=0.05)

    awplot.set_xlabel('Time in [hm]')
    plt.gcf().canvas.draw()

I use this because I plan it on Tkinter Gui and want to update it sometimes. The plot looks like this: enter image description here

My values ​​are:

t = [161000, 161015...., 191115]
aw = [0.618,......, 0.532]
temperature = [23.7,....,24.4]

Is the problem that I am not starting from scratch in the t array?

If someone prompts or knows a problem, please help me.

Cheers max

+5
5

! . , .

, .. .

, - . - - .

:

plot(pTime, pPos)

, :

plot(pTime[ptr:], pPos[ptr:])
plot(pTime[0:ptr], pPos[0:ptr])
+1

Pyplot (x, y) (x, y) , ..... , (?) , x.

x == sorted(x), , . False, .

, , (x, y), plot(), .

+2

. , , .txt, . matplotlib.

, . , . .

, , , .

txt ....

, matplotlib.

,

0

.

365 . 0 365, 1 366, , 366- , 1, , . , 10 .

0

, :

enter image description here

x :

x = sorted(x)

And the line disappeared, as you can see: (But the data is distorted due to sorting).

AFTER SORTINGenter image description here

You must also make sure that the corresponding values ymust also be properly ordered for the sorted one x. The final result is here:

FIXED enter image description here

0
source

All Articles