Python Forum
Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plot correct values
#7
(Feb-16-2017, 07:05 PM)merlem Wrote: There's a difference between a value (as B is) and a list (as T is).

If my understanding of python is correct (I'm not absolute sure in this point), then originB = B makes originB being the same as B, that is, whatever number B is at that time. If I am not wrong, it's kind of a link to a number, and as this number itself is immutable, B = B + cte cannot change originB's target. Therefore, only B is changed.

However, T links to a list. And you will not get a copy of this list, but another link to this list. And the list items are not immutable. Therefore, when you change them, the change will apply to both links, originT and T. 

Therefore, even if the expressions look excactly the same, different things happen, because one of the starting items is a number and the other one is not.

I only wonder why the "fast copy" does not work. Unfortunately, I can't do experiments with your code by myself, as I don't have mathplotlib. Maybe try other ways to get a copy?
Thanks very much for the explanation !!

I'll search for other ways to get a copy as you suggest. I came from C /MatLab and that doesn't happen in those languages .
I need more attention for this question of list, cause I used numpy.array to create "B" and "T". So, I thought that originB = B and originT = T creates arrays too.

Well the most strange is that when I use:

print(type(originT))
print(type(T))
The output is:

Output:
<class 'numpy.ndarray'> <class 'numpy.ndarray'>
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,278 Nov-04-2021, 11:25 PM
Last Post: jefsummers
  How to create correct scatter plot for PCA? LK91 0 2,115 Dec-11-2019, 07:53 PM
Last Post: LK91
  Substituting Values in Plot Hotdog1 2 3,093 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