LK plot() function

  • Paul Gilman
  • Topic Author
More
18 May 2015 18:07 #3348 by Paul Gilman
LK plot() function was created by Paul Gilman
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,
newplot()
,
plot()
,
axis()
, and
plotopt()
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.

Please Log in or Create an account to join the conversation.

  • christophpan
More
20 May 2015 09: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

Please Log in or Create an account to join the conversation.

  • Paul Gilman
  • Topic Author
More
20 May 2015 16:50 #3350 by Paul Gilman
Replied by Paul Gilman on topic LK plot() function
Dear Chistoph,
Here's an example of how to create a plot with two Y axes:
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
More
22 May 2015 15:06 #3351 by christophpan
Replied by christophpan on topic LK plot() function
Dear Paul,

thank you very much!

regards,
Christoph Pan

Please Log in or Create an account to join the conversation.

  • Paul Gilman
  • Topic Author
More
11 Aug 2015 19:40 #3352 by Paul Gilman
Replied by Paul Gilman 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.

Please Log in or Create an account to join the conversation.

Moderators: Paul Gilman
Powered by Kunena Forum