Hi I have a code that plots 2D data from a .dat file (I'll call it filename.dat which is just a .dat file with 2 columns of numbers). It works fine, I just have some questions as to how to improve it.
How can I edit my code to make the axes label larger and add a title? This code is not so easy to edit the way I have it written now. I have tried adding the fontsize,title into the plotfile(...) command, but this did not work. Thanks for the help! My code is below.
import numpy as np
import matplotlib.pyplot as plt
#unpack file data
dat_file = np.loadtxt("filename.dat",unpack=True)
plt.plotfile('filename.dat', delimiter=' ',cols=(0,1), names=('x','y'),marker='0')
I assume you want to add them to the plot.
You can add a title with:
and you add text to the graph with
# the following coordinates need to be determined with experimentation # put them at a location and move them around if they are in # the way of the graph x = 5 y = 10 plt.text(x,y, "Your comment")
This can help you with the font sizes: