Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to make hollow square marks with matplotlib in python

Black line in the following graph is plotting using the below command for matplotlib python

pylab.semilogy(xaxis, pq_averages, 'ks-',color='black', label='DCTCP-PQ47.5')

So 'ks-' part indicates solid line with square black marks. So it had solid squares for the plotted points. Can these squares be made hollow instead?

enter image description here

like image 631
vaichidrewar Avatar asked Jun 08 '12 22:06

vaichidrewar


People also ask

How do I use marker in Matplotlib?

Render the string using mathtext. E.g “$r$” for marker showing the letter r. A list of (x, y) pairs used for Path vertices. The center of the marker is located at (0, 0) and the size is normalized, such that the created path is encapsulated inside the unit cell.

How do you mark points on a plot in Python?

Lay out a grid in the current line style. Plot x and y using plot() method with marker="o", markeredgecolor="red", markerfacecolor="green". To display the figure, use show() method.

How do I make a square in Matplotlib?

We can set the aspect ratio of a plot using the set_aspect() method to make it a square plot and axis() method can also be used to make a square plot with equal axes in Matplotlib.

How do I make the dots transparent in Matplotlib?

Adjust the Transparency of Scatter PointsUtilize the alpha argument in our scatter method and pass in a numeric value between 0 and 1. A value of 0 will make the plots fully transparent and unable to view on a white background. A value of 1 is the default with non-transparent points.


2 Answers

Try adding markerfacecolor like so:

pylab.semilogy(xaxis, pq_averages, 'ks-', markerfacecolor='none', label='DCTCP-PQ47.5')
like image 80
Hugh Bothwell Avatar answered Oct 19 '22 19:10

Hugh Bothwell


Setting markerfacecolor='white' does not actually make them hollow, it makes them white. In order to make them hollow, you need to set markerfacecolor='none'. Additionally, you need to set markeredgecolor to the color you want. So:

pylab.semilogy(xaxis, pq_averages, 'ks-',color='black',
       label='DCTCP-PQ47.5', markerfacecolor='none', markeredgecolor='black')

Will do the job for you.

like image 11
Saber Avatar answered Oct 19 '22 19:10

Saber