mcsorkun / ChemPlot

A python package for chemical space visualization.
https://chemplot.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
115 stars 31 forks source link

Improving the quality of the figure #10

Open XuanZhoudiffer opened 2 years ago

XuanZhoudiffer commented 2 years ago

Hi, I am the user of the chemplot, I want to use the figure that come out from the chemplot.

But I have two problems:

  1. I want to remove the color of background, and use a transparent or white background. Can you provide this selection for the users?
  2. The scatter points is small for me, and I wan they are larger than the default one. Can you provide the selection of marker size for the users? In this case, the code is nicer to the users. I will thank you vey much if my problems can be solved.
dajtmullaj commented 2 years ago

Hi @XuanZhoudiffer, The figure that comes out of visualize_plot() is a matplotlib.axes.Axes. You can therefore update its values by changing the axis attributes!

  1. For the background for example you can change the facecolor attribute:
    ax = plotter_object.visualize_plot()
    ax.set_facecolor('white')  # Add your desired color here
    ax.figure.savefig(fname='plot.png')
  2. For the dot sizes you can modify the collection of the plot size:
    ax = plotter_object.visualize_plot()
    ax.collections[0].set_sizes([300])  # Add your size here instead of 300
    ax.figure.savefig(fname='plot.png')
dajtmullaj commented 2 years ago

These manipulations require some knowledge of the Axis attributes of matplotlib. I am leaving the issue open as to make it easier we will add the possibility to pass kwargs used by matplotlib.axes.Axes.scatter(), over which the scatter version of visualize_plot() is built on top, directly to visualize_plot(). This way you won't have to manipulate the figure after it is created.