Hello all
I was hoping someone could help me fill in my gaps in my understanding regarding Python Plotting via matplotlib and the Python documentation.
I am plotting some x&y data and customizing the plot using the key word arguments, the code i am using is:-
I wanted to change the edge color of the marker so i went to the matplotlib documentation (https://matplotlib.org/api/_as_gen/matpl...set_marker) and found the following function:-
I am trying to understand how I would incorporate this code, i have tried several different options:-
It is only when I remove the letters "set_" & brackets from the name of the function that it works i.e.:-
So the code that I use to change the marker edge color is:-
My question is why does this work because the source code for this function (shown below) states that the name of the function is set_markeredgecolor NOT markeredgecolor - i thought that in order to call a function you have to call it by the name it was defined as?
I was hoping someone could help me fill in my gaps in my understanding regarding Python Plotting via matplotlib and the Python documentation.
I am plotting some x&y data and customizing the plot using the key word arguments, the code i am using is:-
1 |
pyplot.plot(x,y, label = "Test" ,linestyle = "-" , marker = "o" ,color = "red" , linewidth = 1.5 ) |
1 |
set_markeredgecolor( self , ec) |
1 2 3 |
pyplot.set_markeredgecolor( "blue" ) pyplot.plot(x,y, label = "Test" ,linestyle = "-" , marker = "o" ,color = "red" , linewidth = 1.5 ) #THIS GIVE ME AN ERROR |
1 2 |
pyplot.plot(x,y, label = "Test" ,linestyle = "-" , marker = "o" ,color = "red" , linewidth = 1.5 , set_markeredgecolor( "blue" )) #THIS GIVE ME AN ERROR |
1 2 |
pyplot.plot(x,y, label = "Test" ,linestyle = "-" , marker = "o" ,color = "red" , linewidth = 1.5 , set_markeredgecolor = "blue" ) #THIS GIVE ME AN ERROR |
1 |
set_markeredgecolor( "blue" ) to markeredgecolor = "blue" |
1 |
pyplot.plot(x,y, label = "Test" ,linestyle = "-" , marker = "o" ,color = "red" , linewidth = 1.5 , markeredgecolor = "blue" ) |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
def set_markeredgecolor( self , ec): """ Set the marker edge color. Parameters ---------- ec : color """ if ec is None : ec = 'auto' if ( self ._markeredgecolor is None or np. any ( self ._markeredgecolor ! = ec)): self .stale = True self ._markeredgecolor = ec |