Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%varexp: various improvements #431

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions spyder_kernels/console/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,20 @@ def varexp(line):
ip = get_ipython() #analysis:ignore
funcname, name = line.split()
try:
import guiqwt.pyplot as pyplot
except:
import matplotlib.pyplot as pyplot
pyplot.figure();
getattr(pyplot, funcname[2:])(ip._get_current_namespace()[name])
pyplot.show()
data = ip._get_current_namespace()[name]
except KeyError:
print("\033[41mVariable %s does not exist in current namespace.\033[0m" % name)
plotlib = os.environ.get('SPY_VAREXP_PLOTLIB')
try:
pyplot = __import__(plotlib + '.pyplot', globals(), locals(), [], 0).pyplot
pyplot.figure()
getattr(pyplot, funcname[2:])(data)
pyplot.show()
except (ImportError, ModuleNotFoundError):
print("\033[41mPlease install %s or select an available plotting library "
"in Variable Explorer preferences.\033[0m" % plotlib)
except Exception:
ip.showtraceback(sys.exc_info())


def main():
Expand Down
Loading