Skip to content
This repository has been archived by the owner on Feb 28, 2020. It is now read-only.

Error in running script, plot is not defined? #2

Open
HenryPD96 opened this issue Jan 2, 2018 · 9 comments
Open

Error in running script, plot is not defined? #2

HenryPD96 opened this issue Jan 2, 2018 · 9 comments

Comments

@HenryPD96
Copy link

I have been trying to run the test.py script to see if it works and I keep getting 'NameError: plot is not defined'?

Can you help me on this please?

I have attached a screenshot of my terminal window and the script which I used.

Many Thanks,

Henry
error rxnlvl

`#! /usr/bin/python

Boilerplate

import sys
sys.path.insert(1,"C:\Users\Henry\rxnlvl") #

Plot

p = plot([25.0,10.0],vbuf=10.0,hbuf=5.0,bgcolour=None, qualified='sortof')

p + level(energy( 00, 'kjmol'), 1, '1', 0x0)
p + level(energy( -85.5, 'kjmol'), 2, 'EC1', 0x0)
p + level(energy( 244, 'kjmol'), 3, 'TS1a', 0xFF4444)
p + level(energy( 51, 'kjmol'), 3, 'TS1b', 0x0)
p + level(energy( -102, 'kjmol'), 4, 'DC1', 0x0)
p + level(energy( -82, 'kjmol'), 5, '2', 0x0)
p + level(energy( -111, 'kjmol'), 6, 'EC2', 0x0)
p + level(energy( -83, 'kjmol'), 7, 'TS2b', 0x0)
p + level(energy( 18, 'kjmol'), 7, 'TS2a', 0x44FF44)
p + level(energy( -103, 'kjmol'), 8, 'DC2', 0x0)
p + level(energy( 85, 'kjmol'), 9, '3', 0x0)
p + level(energy( 185, 'kjmol'), 10, '4', 0x0)
p + level(energy( 25, 'kjmol'), 11, '5', 0x0)

p + edge( '1', 'EC1', 0x0, 0.4, 'normal')
p + edge( 'EC1', 'TS1a', 0x0, 0.2, 'normal')
p + edge( 'EC1', 'TS1b', 0x0, 0.4, 'normal')
p + edge( 'TS1a', 'DC1', 0x0, 0.2, 'normal')
p + edge( 'TS1b', 'DC1', 0x0, 0.4, 'normal')
p + edge( 'DC1', '2', 0x0, 0.4, 'normal')
p + edge( '2', 'EC2', 0x0, 0.4, 'normal')
p + edge( 'EC2', 'TS2b', 0x0, 0.4, 'normal')
p + edge( 'EC2', 'TS2a', 0x0, 0.2, 'normal')
p + edge( 'TS2a', 'DC2', 0x0, 0.2, 'normal')
p + edge( 'TS2b', 'DC2', 0x0, 0.4, 'normal')
p + edge( 'DC2', '3', 0x0, 0.4, 'normal')
p + edge( '3', '4', 0x0, 0.4, 'normal')
p + edge( '4', '5', 0x0, 0.4, 'normal')

p + baseline(energy( 0.0, 'kjmol'),colour=0x0,mode='dashed',opacity=0.1)

p.write()

@esguerra
Copy link

esguerra commented Jan 2, 2018

Hi,
It might be a python3 problem. Which python version are you using?

Try running the test with:

python2.7 test.py

@HenryPD96
Copy link
Author

HenryPD96 commented Jan 3, 2018 via email

@ericchansen
Copy link

You can see from your error message that plot isn't defined. You have to import it (from here). For the test script to work as the author intended, you have to edit line 5, which could be one reason (out of many) that it's not working.

You'll probably need some degree of Python knowledge to get this package to do what you'd like it to do. Here's a pretty well written introduction to how import works in Python. I'd start there.

@HenryPD96
Copy link
Author

That's great thank you very much, I'll try this. What does the import * on line 6 mean? Do I have to change the * to something else?

I'll have a read of that introduction, if you could advise me further I'd appreciate it very much.

@HenryPD96
Copy link
Author

I have done as suggested but now cannot find the outputted file. Here is the code:

`#! /usr/bin/python
import matplotlib.pyplot as plt

Boilerplate

import sys
sys.path.insert(1,"/Users/henry/Desktop/rxnlvl-master/rxnlvl")
from rxnlvl import *

Plot

p = plot([25.0,10.0],vbuf=10.0,hbuf=5.0,bgcolour=None, qualified='sortof')

p + level(energy( 00, 'kjmol'), 1, '1', 0x0)
p + level(energy( -85.5, 'kjmol'), 2, 'EC1', 0x0)
p + level(energy( 244, 'kjmol'), 3, 'TS1a', 0xFF4444)
p + level(energy( 51, 'kjmol'), 3, 'TS1b', 0x0)
p + level(energy( -102, 'kjmol'), 4, 'DC1', 0x0)
p + level(energy( -82, 'kjmol'), 5, '2', 0x0)
p + level(energy( -111, 'kjmol'), 6, 'EC2', 0x0)
p + level(energy( -83, 'kjmol'), 7, 'TS2b', 0x0)
p + level(energy( 18, 'kjmol'), 7, 'TS2a', 0x44FF44)
p + level(energy( -103, 'kjmol'), 8, 'DC2', 0x0)
p + level(energy( 85, 'kjmol'), 9, '3', 0x0)
p + level(energy( 185, 'kjmol'), 10, '4', 0x0)
p + level(energy( 25, 'kjmol'), 11, '5', 0x0)

p + edge( '1', 'EC1', 0x0, 0.4, 'normal')
p + edge( 'EC1', 'TS1a', 0x0, 0.2, 'normal')
p + edge( 'EC1', 'TS1b', 0x0, 0.4, 'normal')
p + edge( 'TS1a', 'DC1', 0x0, 0.2, 'normal')
p + edge( 'TS1b', 'DC1', 0x0, 0.4, 'normal')
p + edge( 'DC1', '2', 0x0, 0.4, 'normal')
p + edge( '2', 'EC2', 0x0, 0.4, 'normal')
p + edge( 'EC2', 'TS2b', 0x0, 0.4, 'normal')
p + edge( 'EC2', 'TS2a', 0x0, 0.2, 'normal')
p + edge( 'TS2a', 'DC2', 0x0, 0.2, 'normal')
p + edge( 'TS2b', 'DC2', 0x0, 0.4, 'normal')
p + edge( 'DC2', '3', 0x0, 0.4, 'normal')
p + edge( '3', '4', 0x0, 0.4, 'normal')
p + edge( '4', '5', 0x0, 0.4, 'normal')

p + baseline(energy( 0.0, 'kjmol'),colour=0x0,mode='dashed',opacity=0.1)

p.write()`

The output from this code is attached - what have I done wrong?

Please help!

Henry
Terminal Saved Output.pdf

@esguerra
Copy link

esguerra commented Jan 3, 2018

Hi,

That is the expected result.
The format is svg.
If you change the extension of the produced file to svg, you should be able to see it.

@esguerra
Copy link

esguerra commented Jan 3, 2018

Try this:

python2.7 test.py > energyplot.svg

Then you should be able to see the svg file.

@esguerra
Copy link

esguerra commented Jan 3, 2018

@ericchansen
Copy link

It looks like the write function in the plot class is trying to piece together the contents of an SVG file inside the svgstring variable. It writes svgstring to standard output, which you could redirect to a file. Perhaps try something like python test.py > outputfile.svg. Most operating systems and browsers can display SVG files.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants