ChemPlot icon indicating copy to clipboard operation
ChemPlot copied to clipboard

Improving the quality of the figure

Open XuanZhoudiffer opened this issue 3 years ago • 2 comments

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.

XuanZhoudiffer avatar Sep 13 '22 13:09 XuanZhoudiffer

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')
  1. 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 avatar Sep 27 '22 11:09 dajtmullaj

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.

dajtmullaj avatar Sep 27 '22 11:09 dajtmullaj