Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize academic scatter Diagram with matplotlib in Python

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how matplotlib in Python implements academic scatter plots. Xiaobian thinks it is quite practical, so share it with you for reference. I hope you can gain something after reading this article.

To plot the academic correlation plot of the upper and lower error lines, you also need to add the upper line and bottom line of the best fit, which are drawn according to 1:1 best line and error Δτ= ± (0.05+0.15 True data , corresponding to y=1.15×+0.05 (upper line) and y=0.85×−0.05 (bottom line), respectively. Based on this, our key code for drawing error bars is as follows:

#Used to draw best-fit line x2 = np.linspace(-10,10 $> y2 =x2#Draw upper lineup_y2 = 1.15*x2 + 0.05#Draw bottom linedown_y2 = 0.85*x2 - 0.05#Add upper and lower lines ax.plot(x2,up_y2,color='k', lw=1.5,ls='--', zorder=2)ax.plot(x2,down_y2,color='k', lw=1.5,ls='--', zorder=2)

The chart results are as follows:

Draw an error line with a colorbar dotted correlation plot as follows:

Based on the above line drawing is basically over, if there are other lines drawn, I will add later, or you provide other lines needed to draw.

03. Change font settings for academic charts. General journals require Times New Roman fonts for numbers and letters. This is the case for journals I vote for.

Of course, this is not completely uniform. It is related to the requirements of the journal submitted. There are small partners in the communication group who suggest changing it to Arial. Here, we will explain the unified modification of fonts to avoid the tedious modification of fonts one by one. The key code of the modified code is as follows:

#uniformly modify font plt.rcParams ('font.family')=('Arial ')

After using the above code, the code corresponding to the partial modification of the font should be deleted. The results were as follows:

04. Python-matplotlib is also a simple way to draw multiple subgraphs. Below, black and white scatter and color scatter are drawn at the same time to avoid later typesetting operations. The specific codes are as follows:

The results were as follows:

05. correlation scatter type

The following types of scatter plots are seen in other papers, as follows:

(This picture comes from the Internet. If it is infringing, please inform us to delete it)

Python-matplotlib is also relatively simple to draw such correlation scatter plots, the core code is as follows:

#grid settings ax.grid(which='major', axis=' y', ls='--',c='k', alpha=.7)ax.set_axisbelow(True)#axis ridge settings for spine in ['top','left',' right']: ax.spines[spine].set_visible(None) #Hide axis spines ax.spines <$'bottom '].set_color ('k') #Set bottom color #Scale setting, only bottom scales are displayed, and the direction is outward, length and width are also set ax.tick_params(bottom=True,direction='out', labelsize=14,width=1.5,length=4, left=False)

The rest is the same as the previous tweet tutorial, and the results are as follows:

Scale interval settings can also be customized, as follows:

#Set tick interval from matplotlib.pyplot import MultipleLocator x_major_locator=MultipleLocator(.5)y_major_locator=MultipleLocator(.5)

ax.xaxis.set_major_locator(x_major_locator)ax.yaxis.set_major_locator(y_major_locator) About "Python matplotlib how to achieve academic scatter plot" This article is shared here, I hope the above content can have some help for everyone, so that you can learn more knowledge, if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report