Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plot correct values
#1
Hi guys,

I wrote a code to make corrections in array data and plot the after/before for that.

Here's my code:

while ctr2 == 'R':
                cte = float(input('Type the constant: '))
                plt.close()
                originB = B
                originT = T
                B = B + cte
                dx = len(T)
                for i in range(dx):
                    if T[i] >= 0:
                        print(T[i])
                        T[i] = T[i] + cte
                        print(T[i])
                    else:
                        T[i] = T[i] - cte
                print(T)
                f, axarr = plt.subplots(2, sharex=True)
                axarr[0].plot(X,B,'-',X,originB,'--')
                axarr[0].set_title('Modulo')
                axarr[1].plot(X,T,'-',X,originT,'--')
                axarr[1].set_title('Anomalia')
                plt.show(block=False)

                ctr2 = input('Type R to remove a constant or E to exit: ')
I store the the values before changes in "originB" and "originT" arrays. So I use the value of the constant "cte" to performe the corrections. For the "B" array it's a simple sum, but for the "T" array I need to check the elements to decide if I sum or subtract the value of "cte". When I plot, the graph for "B" it's ok, but for "T" it plots in the same position of the values stored in "originT". Look that I put some prints to check if the values of "T" are changing correctly and they are.

Here's my output. The values for B are plotted in the subplot called "Modulo" and for T in the subplot called "Anomalia".  For this example I used the values for "originB" and "originT" equals to zero and for "cte" equal to one:

Output:
[img]https://drive.google.com/open?id=0B-HZ-2g-lyoUX19IeG4yR19WQU0[/img]
I appreciate the help !!
Reply


Messages In This Thread
Plot correct values - by Felipe - Feb-16-2017, 01:38 PM
RE: Plot correct values - by merlem - Feb-16-2017, 04:03 PM
RE: Plot correct values - by Felipe - Feb-16-2017, 04:45 PM
RE: Plot correct values - by merlem - Feb-16-2017, 05:13 PM
RE: Plot correct values - by Felipe - Feb-16-2017, 06:17 PM
RE: Plot correct values - by merlem - Feb-16-2017, 07:05 PM
RE: Plot correct values - by Felipe - Feb-16-2017, 10:43 PM
RE: Plot correct values - by merlem - Feb-17-2017, 08:29 AM
RE: Plot correct values - by Felipe - Feb-17-2017, 11:57 AM
RE: Plot correct values - by merlem - Feb-18-2017, 09:21 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Matplotlib scatter plot in loop with None values ivan_sc 1 2,273 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  How to create correct scatter plot for PCA? LK91 0 2,107 Dec-11-2019, 07:53 PM
Last Post: LK91
  Substituting Values in Plot Hotdog1 2 3,079 Nov-11-2017, 08:07 PM
Last Post: Hotdog1

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020