I have a graph like this.
the code I wrote for this is below:
header=list(outcome)
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.patches as mpatches
fig = plt.figure(figsize=(25,20))
ax = fig.add_subplot(111, projection='3d')
red_patch = mpatches.Patch(color='red', label='Terminated')
green_patch = mpatches.Patch(color='green', label='Completed Positive')
blue_patch=mpatches.Patch(color='blue', label='Completed Negative')
plt.legend(handles=[red_patch,green_patch,blue_patch],fontsize=23)
plt.title('MDS by Phase '+phase,fontsize=23)
for x, y, w, name in zip(pos[:, 0], pos[:,1], pos[:, 2], header):
if(name=='Completed Negative'):
color='blue'
elif(name=='Completed Positive'):
color='green'
else:
color='red'
ax.scatter(x, y, w,s=65,c=color)
#fig.savefig('mds_ic_'+phase+'.png')
fig.savefig('mds_obj_auto_'+phase+'.png')
I don't want the black background as when pasting the graph on a slide it is taking too much space but appears small since the remaining space is white which is not part of the graph. The black portion doesn't gel with the white background
You could try adding the following lines:
fig.patch.set_facecolor('white')
ax.set_axis_bgcolor('white')
ax.w_xaxis.set_pane_color((1.0, 1.0, 1.0, 1.0))
ax.w_yaxis.set_pane_color((1.0, 1.0, 1.0, 1.0))
ax.w_zaxis.set_pane_color((1.0, 1.0, 1.0, 1.0))
One to remove the background from around the figure, one to change the axis colour, and the last three to change each axis's pane colour.
If you want a black background it is easiest to set matplotlib.pyplot.style.use('dark_background')
.
You can choose a style from matplotlib.pyplot.style.available
and set your choice via use
, eg matplotlib.pyplot.style.use('ggplot')
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.