AstroJacobLi / smplotlib

Matplotlib template for SuperMongo style 🔭
MIT License
124 stars 8 forks source link

Scatter plots do not show face colour #1

Closed fdeugenio closed 1 year ago

fdeugenio commented 1 year ago

Hi, great library! I was wondering whether you can create scatter plots with the symbols colour coded, e.g.:

import numpy as np
v = np.arange(10)
plt.scatter(v, v, c=v)

With smplotlib, all symbols are empty white circles, but without smplotlib, the symbols are coloured. Perhaps this is a deliberate style choice, but just wanted to report in case it's not!

AstroJacobLi commented 1 year ago

Hi there! Thanks for rasing this issue. I tested it using the latest version of smplotlib on pip (https://pypi.org/project/smplotlib/), and I got the following figure without the problem that you reported: image

Maybe can you try to upgrade the package by pip install smplotlib -U?

fdeugenio commented 1 year ago

I tried that but get the same results, differently from what you display. I have this setup matplotlib 3.7.1 smplotlib 0.0.8 Python 3.10.9

AstroJacobLi commented 1 year ago

Okay I was using a much older version of matplotlib. And I can reproduce your issue when using matplotlib 3.7.1. I'll try to fix it later. Thanks for raising the issue!

AstroJacobLi commented 1 year ago

Hi @fdeugenio! I think I've fixed the problem. The figure below is generated using the latest smplotlib==0.0.9 and the following code:

import numpy as np
v = np.arange(10)
plt.scatter(v, v, c=v)
plt.text(5.5, 2, r'Normal Text', fontsize=18)
plt.text(5.5, 2.5, r'$\mathbf{mathbf}$', fontsize=18)
plt.text(5.5, 3, r'$\mathit{mathit}$', fontsize=18)
plt.text(5.5, 3.5, r'$\mathsf{mathsf}$', fontsize=18)
plt.text(5.5, 4, r'$\mathtt{mathtt}$', fontsize=18)

image

This demonstrates the different types of fonts in the Hershey font family. If you don't like the black edge around the data points, you can turn it off by smplotlib.set_style(edgecolor='face'). The default colormap is jet, to mimic those shining old figures, you know...

fdeugenio commented 1 year ago

Awesome, thank you! I also learned about fillstyle looking at your commit