Python Forum
Setting Marker Edge Color In Plotting
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Setting Marker Edge Color In Plotting
#1
Photo 
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:-

1
pyplot.plot(x,y, label = "Test",linestyle="-", marker="o",color="red", linewidth=1.5)
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:-

1
set_markeredgecolor(self, ec)
I am trying to understand how I would incorporate this code, i have tried several different options:-

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
It is only when I remove the letters "set_" & brackets from the name of the function that it works i.e.:-

1
set_markeredgecolor("blue") to markeredgecolor = "blue"
So the code that I use to change the marker edge color is:-

1
pyplot.plot(x,y, label = "Test",linestyle="-", marker="o",color="red", linewidth=1.5, markeredgecolor = "blue")
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?

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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem When using canny edge detection,black image returned rickyw2777 1 402 Feb-17-2025, 03:22 AM
Last Post: rickyw2777
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 3,232 Oct-25-2023, 09:09 AM
Last Post: codelab
  Python Networkx: Visualize an edge weight with a bubble/circle uvw 0 2,869 Sep-01-2021, 06:26 AM
Last Post: uvw
  How do I apply a Gaussian blur to a particular edge of geometry in Matplotlib? hbolandi 0 2,601 Feb-02-2020, 06:08 PM
Last Post: hbolandi
  rising edge of detection peter14 7 14,437 Dec-27-2018, 10:27 AM
Last Post: peter14
  Randomise network while maintaining topology of nodes using edge-swap approach Tom1988 3 5,105 May-25-2017, 10:59 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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