Closed alkirkby closed 5 years ago
seems like the plotting object is created but the plotting code is not run.
try add the following line before plt.save_figure()
prObj.plot()
and I cannot find prObj.save_figure()
in file mtpy/imaging/plot_response.py
is it the module you are using?
if it is, the function "save_figure" is actually a private method _save_figure()
for some reason, may this need to be fixed.
I have tried adding prObj.plot(), the figure displays to the screen but still saves to a blank figure. Also, to clarify I am using PlotResponse in mtpy.modeling.modem not in imaging, where there is a save_figure method.
I noticed that this issue seems to only come up when running from an iPython console, when I run in spyder in a standard python console, i don't get the issue.
I'm having this problem as well. How exactly did you fix it? I've tried running a plotting script in iPython console, windows powershell and spyder but still get blank output images from prObj.save_figure.
Hi Tom, Could you please provide the code you're using and confirm that you've pulled the latest version? I just tested the following example in spyder: C:\mtpywin\mtpy\examples\scripts\ModEM_PlotResponse.py and it worked fine for me.
Hi Alison, I've just pulled the latest version and have tried running the same ModEM_PlotResponse.py example script you mention but the issue persists. Running the script in git-bash and Spyder opens a plot, but the output of the save_figure line is empty.
Script I used: `# -- coding: utf-8 -- """ Created on Tue Oct 04 13:13:29 2016
@author: Alison Kirkby
Plot data and responses from ModEM model. To plot data only, comment out resp_fn line in PlotResponse """ import os
from mtpy.modeling.modem import PlotResponse
wd = r'C:\mtpywin\mtpy\examples\model_files\ModEM_2'
savepath = r'C:\mtpywin'
filestem = 'Modular_MPI_NLCG_004' datafn = 'ModEM_Data.dat'
plot_z = False respfn = filestem+'.dat' station = 'Synth02'
ro = PlotResponse(data_fn=os.path.join(wd,datafn), resp_fn=os.path.join(wd,respfn), plot_type=[station], plot_style=2, # 1 for 4-colums; 2 for 2-columns plot_z=False, fig_size=[3,2], font_size=4 )
ro.save_figure(os.path.join(savepath,'response.png'), fig_dpi=400) # change fig_dpi to your desired resolution
ro.plot()`
Hi Tom, In your script below the ro.plot() line is after ro.save_figure but in the example (mtpy\examples\scripts\ModEM_PlotResponse.py), ro.plot is first. When I put ro.save_figure before ro.plot i get the same issue as you describe. Can you reverse these two lines and try again?
Hi Alison, this did the job. Cheers!
No worries - glad it worked, I'll close the issue.
plots saving to a blank figure
Expected Behavior
Would like to save the plot that comes to screen
Current Behavior
plot is coming up fine but saves to a blank figure
Context
Your Environment
Installed Python Packages: alabaster 0.7.10 py27_0 conda-forge asn1crypto 0.22.0 py27_0 conda-forge astroid 1.5.3 py27_0 conda-forge babel 2.4.0 py27_0 conda-forge backports 1.0 py27_1 conda-forge backports.functools_lru_cache 1.4 py27_1 conda-forge backports.shutil_get_terminal_size 1.0.0 py27_1 conda-forge backports_abc 0.5 py27_0 conda-forge basemap 1.1.0 py27_3 conda-forge bleach 2.0.0 py27_0 conda-forge ca-certificates 2017.7.27.1 0 conda-forge certifi 2017.7.27.1 py27_0 conda-forge cffi 1.10.0 py27_0 conda-forge chardet 3.0.4 py27_0 conda-forge click 6.7 py27_0 conda-forge click-plugins 1.0.3 py27_0 conda-forge cligj 0.4.0 py27_0 conda-forge colorama 0.3.9 py27_0 conda-forge configparser 3.5.0 py27_0 conda-forge cryptography 2.0.3 py27_0 conda-forge curl 7.55.1 vc9_0 [vc9] conda-forge cycler 0.10.0 py27_0 conda-forge decorator 4.1.2 py27_0 conda-forge descartes 1.1.0 py27_0 conda-forge docutils 0.14 py27_0 conda-forge entrypoints 0.2.3 py27_1 conda-forge enum34 1.1.6 py27_1 conda-forge expat 2.1.0 vc9_3 [vc9] conda-forge fiona 1.7.9 py27_1 conda-forge freetype 2.7 vc9_1 [vc9] conda-forge freexl 1.0.2 vc9_2 [vc9] conda-forge funcsigs 1.0.2 py_2 conda-forge functools32 3.2.3.2 py27_1 conda-forge future 0.16.0 py27_0 conda-forge gdal 2.1.3 py27_vc9_7 [vc9] conda-forge geopandas 0.3.0 py27_0 conda-forge geos 3.6.2 vc9_1 [vc9] conda-forge hdf4 4.2.12 vc9_0 [vc9] conda-forge hdf5 1.10.1 vc9_1 [vc9] conda-forge html5lib 0.999999999 py27_0 conda-forge icu 58.1 vc9_1 [vc9] conda-forge idna 2.5 py27_0 conda-forge imagesize 0.7.1 py27_0 conda-forge ipaddress 1.0.18 py27_0 conda-forge ipykernel 4.6.1 py27_0 conda-forge ipython 5.4.1 py27_0 conda-forge ipython_genutils 0.2.0 py27_0 conda-forge ipywidgets 7.0.5 py27_0 conda-forge isort 4.2.15 py27_0 conda-forge jedi 0.10.2 py27_0 conda-forge jinja2 2.9.6 py27_0 conda-forge jpeg 9b vc9_0 [vc9] conda-forge jsonschema 2.5.1 py27_0 conda-forge jupyter 1.0.0 py27_0 conda-forge jupyter_client 5.1.0 py27_0 conda-forge jupyter_console 5.2.0 py27_0 conda-forge jupyter_core 4.3.0 py27_0 conda-forge kealib 1.4.7 vc9_4 [vc9] conda-forge krb5 1.14.2 vc9_0 [vc9] conda-forge lazy-object-proxy 1.3.1 py27_0 conda-forge libiconv 1.14 vc9_4 [vc9] conda-forge libnetcdf 4.4.1.1 vc9_10 [vc9] conda-forge libpng 1.6.28 vc9_2 [vc9] conda-forge libpq 9.6.3 vc9_0 [vc9] conda-forge libspatialindex 1.8.5 vc9_1 [vc9] conda-forge libspatialite 4.3.0a vc9_18 [vc9] conda-forge libssh2 1.8.0 vc9_2 [vc9] conda-forge libtiff 4.0.6 vc9_7 [vc9] conda-forge libxml2 2.9.3 vc9_9 [vc9] conda-forge libxslt 1.1.29 vc9_5 [vc9] conda-forge lxml 3.8.0 py27_0 conda-forge markupsafe 1.0 py27_0 conda-forge matplotlib 2.1.1 py27_0 conda-forge mccabe 0.6.1 py27_0 conda-forge mistune 0.7.4 py27_0 conda-forge mkl 2017.0.3 0 mock 2.0.0 py27_0 conda-forge munch 2.2.0 py27_0 conda-forge nbconvert 5.2.1 py27_1 conda-forge nbformat 4.3.0 py27_0 conda-forge netcdf4 1.3.1 py27_2 conda-forge notebook 5.2.2 py27_1 conda-forge numpy 1.12.1 py27_0 numpydoc 0.7.0 py27_0 conda-forge obspy 1.1.0 py27_1 conda-forge olefile 0.44 py27_0 conda-forge openjpeg 2.1.2 vc9_3 [vc9] conda-forge openssl 1.0.2l vc9_0 [vc9] conda-forge pandas 0.20.3 py27_1 conda-forge pandoc 1.19.2 0 conda-forge pandocfilters 1.4.1 py27_0 conda-forge pathlib2 2.3.0 py27_0 conda-forge pbr 3.1.1 py27_0 conda-forge pcre 8.39 vc9_0 [vc9] conda-forge pep8 1.7.0 py27_0 conda-forge pickleshare 0.7.4 py27_0 conda-forge pillow 4.3.0 py27_1 conda-forge pip 9.0.1 py27_0 conda-forge proj4 4.9.3 vc9_4 [vc9] conda-forge prompt_toolkit 1.0.15 py27_0 conda-forge psutil 5.2.2 py27_0 conda-forge psycopg2 2.7.3 py27_0 conda-forge pycodestyle 2.3.1 py27_0 conda-forge pycparser 2.18 py27_0 conda-forge pyflakes 1.6.0 py27_0 conda-forge pygments 2.2.0 py27_0 conda-forge pylint 1.7.1 py27_0 conda-forge pyopenssl 17.2.0 py27_0 conda-forge pyparsing 2.2.0 py27_0 conda-forge pyproj 1.9.5.1 py27_0 conda-forge pyqt 5.6.0 py27_4 conda-forge pysal 1.13.0 py27_0 conda-forge pyshp 1.2.12 py_0 conda-forge pysocks 1.6.7 py27_0 conda-forge python 2.7.13 1 conda-forge python-dateutil 2.6.1 py27_0 conda-forge pytz 2017.2 py27_0 conda-forge pyyaml 3.12 py27_1 conda-forge pyzmq 16.0.2 py27_2 conda-forge qt 5.6.2 vc9_2 [vc9] conda-forge qtawesome 0.4.4 py27_0 conda-forge qtconsole 4.3.1 py27_0 conda-forge qtpy 1.3.1 py27_0 conda-forge requests 2.18.4 py27_1 conda-forge rope 0.10.7 py27_0 conda-forge rtree 0.8.3 py27_0 conda-forge scandir 1.5 py27_1 conda-forge scipy 0.19.1 np112py27_0 setuptools 36.3.0 py27_0 conda-forge shapely 1.6.3 py27_0 conda-forge simplegeneric 0.8.1 py27_0 conda-forge singledispatch 3.4.0.3 py27_0 conda-forge sip 4.18 py27_1 conda-forge six 1.10.0 py27_1 conda-forge snowballstemmer 1.2.1 py27_0 conda-forge sphinx 1.6.3 py27_0 conda-forge sphinxcontrib-websupport 1.0.1 py27_0 conda-forge spyder 3.2.4 py27_0 conda-forge sqlalchemy 1.1.13 py27_0 conda-forge sqlite 3.13.0 vc9_1 [vc9] conda-forge ssl_match_hostname 3.5.0.1 py27_1 conda-forge testpath 0.3.1 py27_0 conda-forge tornado 4.5.2 py27_0 conda-forge traitlets 4.3.2 py27_0 conda-forge typing 3.6.2 py27_0 conda-forge urllib3 1.22 py27_0 conda-forge vc 9 0 conda-forge vs2008_runtime 9.00.30729.5054 0 wcwidth 0.1.7 py27_0 conda-forge webencodings 0.5 py27_0 conda-forge wheel 0.29.0 py27_0 conda-forge widgetsnbextension 3.0.8 py27_0 conda-forge win_inet_pton 1.0.1 py27_1 conda-forge win_unicode_console 0.5 py27_0 conda-forge wincertstore 0.2 py27_0 conda-forge wrapt 1.10.11 py27_0 conda-forge xerces-c 3.2.0 vc9_0 [vc9] conda-forge yaml 0.1.6 vc9_0 [vc9] conda-forge zlib 1.2.11 vc9_0 [vc9] conda-forge