Mar-17-2021, 01:19 PM
Distinguished colleagues, good morning.
I am working on building a graph using matplotlib and I am facing some difficulties.
How can I leave the X-axis in the base ten format raised to an exponent? For example, 10³. The graph places a scale factor of 1 and 7 on the right side of the axis. I would like, for each value of the graph, to have the decimal base accompanying it. For example, 2.10².
Regarding the annotations added at the bottom right of the figure. How can I put a rectangle around these annotations? And yet, how can I leave the text centering inside that rectangle?
Thank you so much for your attention and follow the code below.
I am working on building a graph using matplotlib and I am facing some difficulties.
How can I leave the X-axis in the base ten format raised to an exponent? For example, 10³. The graph places a scale factor of 1 and 7 on the right side of the axis. I would like, for each value of the graph, to have the decimal base accompanying it. For example, 2.10².
Regarding the annotations added at the bottom right of the figure. How can I put a rectangle around these annotations? And yet, how can I leave the text centering inside that rectangle?
Thank you so much for your attention and follow the code below.
from matplotlib import pyplot as plt import numpy as np import pandas as pd x=pd.read_excel(r"C:\pythonprogramas\graficosdoutorado\experimental.xlsx", 'Planilha4') fig = plt.subplots(figsize = (20,10)) plt.xlabel('$\mathbf{Ra_{L_{P}}}$', fontsize=18, fontweight='bold') plt.ylabel('$\mathbf{\overline{N u}_{L_{P}}}$', fontsize=18, fontweight='bold') plt.scatter(x['RaE'], x['NuE'], marker='x', label='Experimental') plt.errorbar(x['RaE'],x['NuE'],yerr=x['ErroE'], color='k', fmt=' ', capsize=5) plt.scatter(x['RaN'], x['NuN'], color='#CC6600', marker='s', label='Numérica') x5 = np.arange(2E6,1.2E7,100000) plt.plot(x5, 1.152347*(x5**0.200198),'--', color='k') plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc='lower left', ncol=3, fontsize=18, mode="expand", borderaxespad=0.) plt.annotate('$\overline{N u}_{L_{P}}=1.152347 \cdot Ra_{L_{P}}^{0,200198}$ \n $\mathrm{R^{2}}=0,952$', size=20, xy=(1.05E7, 29), xytext=(8E6, 21)) plt.ticklabel_format(axis="x", style="sci", scilimits=(0,0)) plt.xlim(2E6, 1.1E7) #plt.xticks(np.arange(2E6, 1.15E7, 5E5),rotation=90) plt.yticks(np.arange(18, 33, 1)) plt.savefig("C:/pythonprogramas/graficosdoutorado/imagens/graficoExp4.png", bbox_inches='tight', pad_inches = 0) plt.show()