NSGeophysics / GPRPy

Ground Penetrating Radar processing and visualization software for python
MIT License
174 stars 84 forks source link

Pulling the GUI Plot #22

Closed danoffenbacker closed 2 years ago

danoffenbacker commented 2 years ago

Just a general question, but has anyone found a method to pull the matplotlib figure from the GPRPy GUI? I would like to be able to modify the plot with annotation, lines, etc., but I cannot seem to find a way to pull the plot (not as a pdf).

AlainPlattner commented 2 years ago

After loading and plotting your profile using "print figure", export this as a python script using the button "write script". In the script you just exported, replace "writeProfile" with "showProfile" and delete the figure filename and the dpi value. For example, if the line was mygpr.writeProfile('C:\mydirectory\myfigure.pdf', color='gray', contrast=1, yrng=[0,48], xrng=[0,20.8], dpi=600) it should now be mygpr.showProfile(color='gray', contrast=1, yrng=[0,48], xrng=[0,20.8]) of course you can also adjust the contrast, color scheme, x and y range.

You can now change any aspect of the figure using the power of maplotlib: On the line after the "mygpr.showProfile" command, add import matplotlib.pyplot as plt See https://matplotlib.org/stable/api/axes_api.html for all the things you can now change.

For example: import matplotlib.pyplot as plt plt.gca().set_xlabel('my new x label') plt.show() changes the x label to "my new x label".

You can turn your figure into a pdf by replacing plt.show() with plt.savefig('myfigname.pdf')