- Posts: 5423
LK plot() function
- pgilman
- Topic Author
Less
More
18 May 2015 12:07 #3348
by pgilman
LK plot() function was created by pgilman
I started using SAM a month ago for my master thesis and would like to write some scripts to simulate PV and CSP systems. As my coding skills are not so proficient I found some troubles using the plotting functions. For example, how do I change the legend position or generate a plot with two y axis? How do I change the ticklabels and what is xap, yap, xlabel, ylabel and so on? The scripting reference lists all possible options for the plots, but I don't know how to use them in the code. Is there a guide where all the options are described?
You can find an example of the LK plotting functions,
,
,
, and
in the Create a Tornado Chart macro. To find it, click Macros at the bottom left corner of the SAM window, and then click Create a Tornado Chart in the list of macros. Click View code in the upper right corner of the window to see the code. The plotting functions are at the end of the macro script.
There was also a discussion of plotting in the webinar on scripting with LK. You can view a recording on the webinar's page: Scripting in SAM with LK .
Best regards,
Paul.
You can find an example of the LK plotting functions,
Code:
newplot()
Code:
plot()
Code:
axis()
Code:
plotopt()
There was also a discussion of plotting in the webinar on scripting with LK. You can view a recording on the webinar's page: Scripting in SAM with LK .
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- christophpan
Less
More
- Posts: 4
20 May 2015 03:37 #3349
by christophpan
Replied by christophpan on topic LK plot() function
Thank you for your answer!
I looked at the Tornado Chart code and figured out some of the things I was looking for, but I still don't know how to generate a plot with two Y-axes. Where do I appoint the data array for the secondary axis to the plot() function?
Kind regards,
Christoph
I looked at the Tornado Chart code and figured out some of the things I was looking for, but I still don't know how to generate a plot with two Y-axes. Where do I appoint the data array for the secondary axis to the plot() function?
Kind regards,
Christoph
Please Log in or Create an account to join the conversation.
- pgilman
- Topic Author
Less
More
- Posts: 5423
20 May 2015 10:50 #3350
by pgilman
Replied by pgilman on topic LK plot() function
Dear Chistoph,
Here's an example of how to create a plot with two Y axes:
The result should be a graph that looks like this:
Best regards,
Paul.
Here's an example of how to create a plot with two Y axes:
Code:
x = [ 1, 2, 3, 4, 5, 6 ];<br />
y1 = [ 1.4, 3, 5, 4, 1, 6 ];<br />
y2 = [ -2.4, 2.3, 0.45, 3.2, 1.1, 5.2 ];<br />
<br />
plot(x,y1, {'yap'='left'});<br />
plot(x,y2, {'yap'='right', 'color'='green'});<br />
<br />
plotopt( { 'title'='Graph with Two Y Axes', 'legend'=false } );<br />
axis( 'y1', { 'label'='Left Y Axis' } );<br />
axis( 'y2', { 'label'='Right Y Axis' } );<br />
axis( 'x1', {'label'='X Axis'} );<br />
<br />
plotout( 'c:/users/paul/desktop/plot.png' );
The result should be a graph that looks like this:
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
- christophpan
Less
More
- Posts: 4
22 May 2015 09:06 #3351
by christophpan
Replied by christophpan on topic LK plot() function
Dear Paul,
thank you very much!
regards,
Christoph Pan
thank you very much!
regards,
Christoph Pan
Please Log in or Create an account to join the conversation.
- pgilman
- Topic Author
Less
More
- Posts: 5423
11 Aug 2015 13:40 #3352
by pgilman
Replied by pgilman on topic LK plot() function
I added a new sample script to the LK Cookbook on the
Samples page
that demonstrates how to use LK plotting functions to create a stacked bar graph, tornado-style graph, and the example above for a line graph with two y axes. The sample also shows how to save an image file of the graph.
Best regards,
Paul.
Best regards,
Paul.
Please Log in or Create an account to join the conversation.
Moderators: pgilman