
forums.silverfrost.com Welcome to the Silverfrost forums

View previous topic :: View next topic 
Author 
Message 
DanRRight
Joined: 10 Mar 2008 Posts: 2684 Location: South Pole, Antarctica

Posted: Wed Mar 15, 2023 3:07 pm Post subject: Request for extension 


Currently %PL allows to plot only 9 curves on the same graph.
As an example the plot looks like this:
This approximately covers 1/2 of evolution i intended to plot.
It is obvious that this limitation on number of curves is too restrictive. Would it be possible to triple or at least double that? 

Back to top 


Kenneth_Smith
Joined: 18 May 2012 Posts: 578 Location: Hamilton, Lanarkshire, Scotland.

Posted: Wed Mar 15, 2023 9:24 pm Post subject: 


Dan, take a look at the %pl[stacked] option. 

Back to top 


DanRRight
Joined: 10 Mar 2008 Posts: 2684 Location: South Pole, Antarctica

Posted: Thu Mar 16, 2023 4:20 am Post subject: 


I know this option. It is extremely cumbersome way to deal with the multiplot actually resembling a hack. Even those ways we discussed lately
http://forums.silverfrost.com/viewtopic.php?t=4547&highlight=multiplot
and which plot nicely
turn out to be inconvenient after some experience with them. I stopped using them. I am asking now about just the standard plotting option to extend it a bit. It also is not ideal, but it's straightforward, simple and stable like all plotting should be.
As a side note, i think that the ideal, shortest, simplest and ultimately intuitive and obvious plotting method of multiple curves should look exactly like this
Code:  I=winio@('%pl[file=settings.set, independent]', n,m,x,y) 
That's all, nothing else, this is complete line. All adjustments should be inside the settings.set file.
Here n(m) is usual dimension of each of m plotted curves, and x and y are twodimensional arrays x(n,m) and y(n,m) with n entries for each of m curves. The number of curves could be here infinite without any difficulties, conflicts or changes
How far is current standard method from ideal? Given its not punishing behavior it is pretty close to ideal. Currently i also use just one line to plot but it is long line like this
Code:  I=winio@('%pl[file=settings9.set, scale=linear, independent,n_graphs=9]', n, x(:,1),y(:,1), x(:,2),y(:,2), x(:,3),y(:,3), x(:,4),y(:,4), x(:,5),y(:,5), x(:,6),y(:,6), x(:,7),y(:,7), x(:,8),y(:,8), x(:,9),y(:,9)) 
and even if i plot only say 3 curves all works OK. If extended to 2030 i will just add more entries, it will be still universal without changes in number of plots in the source code 

Back to top 


PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7584 Location: Salford, UK

Posted: Thu Mar 16, 2023 9:05 am Post subject: 


In the following sample code a callback function is used to make a single plot by caling draw_curvesD@. This call could be repeated for other sets of data.
Code: 
WINAPP
MODULE mymod
USE mswin
INTEGER,PARAMETER::N=11
DOUBLE PRECISION x(N),y(N)
CONTAINS
INTEGER FUNCTION cb()
DOUBLE PRECISION xx(5),yy(5)
CALL set_plot_mode@(1)
CALL set_line_width@(2)
! CALL set_line_style@(PS_DOT)
! CALL draw_polylineD@(x,y,N,RGB@(0,0,255))
CALL draw_curvesD@(x,y,N,RGB@(0,0,255))
! CALL draw_beziersD@(x,y,N,RGB@(0,0,255))
CALL draw_line_betweenD@(0d0, 0d0, x(N), y(N), 255)
CALL draw_line_betweenD@(0d0, 0d0, x(1), y(1), 255)
CALL draw_rectangleD@(0.1d0, 0.1d0, 0.3d0, 0.15d0, RGB@(0,255,0))
CALL draw_filled_ellipseD@(0.1d0, 0.15d0, 0.04d0, 0.02d0, RGB@(0,255,0))
CALL draw_charactersD@("Caption", 0.1d0, 0.2d0, 0)
xx = (/0d0, 0.05d0, 0.05d0, 0d0, 0d0/)
yy = (/0d0, 0d0, 0.035d0, 0.035d0, 0d0/)
CALL draw_filled_polygonD@(xx,yy,5,RGB@(0,0,255))
CALL draw_symbolsD@(x,y,N,11,5,255)
CALL set_plot_mode@(0)
cb = 2
END FUNCTION
END MODULE mymod
PROGRAM main
USE mymod
INTEGER i
DO i=1,N
x(i)=0.1d0*(i6)
y(i)=x(i)*x(i)
ENDDO
i=winio@('%ca[Quadratic]%pv&')
CALL winop@("%pl[title=Graph]") !graph title
CALL winop@("%pl[y_max=0.25]") !maximum y value on axis
CALL winop@("%pl[x_array]") !the data provides other max and min values
CALL winop@("%pl[smoothing=5]")
CALL winop@("%pl[link=user]") !all lines and symbols drawn via set_plot_mode@
CALL winop@("%pl[frame]")
i=winio@('%^pl&',400,250,N,x,y,cb)
i=winio@('%sf%ff%nl%cn%tt[OK]')
END



Back to top 


DanRRight
Joined: 10 Mar 2008 Posts: 2684 Location: South Pole, Antarctica

Posted: Thu Mar 16, 2023 10:41 am Post subject: 


Paul,
This is exactly how i made (with the help of Ken) this nice colorful plot above. It took me several days by the way. It is serving as one of my general purpose plots in the program. But what i found when tried to duplicate it and create similar plot for other part of the same program  this required me more efforts than it worth to spend time on it because to make it work flawlessly definitely will need some debug time and such code is tens and tens of lines long.
So i ended with the standard plotting way (first my plot above) which if needed could be made similarly colorful via Settings (excluding these nice Legend numbering at the right hand side of the plot but that would take even more time)
This is why i ask to just to extend the standard %PL plotting to handle 2030 graphs instead of 9 currently. I hope this would not require much efforts. I do plots like that for different tasks happens sometimes few times per week. 

Back to top 


PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7584 Location: Salford, UK

Posted: Thu Mar 16, 2023 12:23 pm Post subject: 


Here is another sample. In this case there are 20 plots and the ydata is stored in a 2dimensional array.
Code:  WINAPP
USE clrwin
INTEGER M,N,i
PARAMETER(N=11,M=20)
REAL*8 xm,x(N),y(N,M)
CHARACTER(len=24) str
DO i=1,N
xx = 0.1d0*(i1)
x(i) = xx
xm = 0.1d0
! Replace this DO loop with data for each plot...
DO j=0,M1
y(i,j+1) = xm*xx
xm = xm + 0.1d0
ENDDO
ENDDO
i=winio@("%ca[Multigraph]&")
CALL winop@("%pl[n_graphs=20]") !20=M
CALL winop@("%pl[stacked]")
CALL winop@("%pl[x_array]")
CALL winop@("%pl[x_max=1.0]")
CALL winop@("%pl[dx=0.1]")
CALL winop@("%pl[smoothing=4]")
!Various line colours going from blue to red...
DO j=1,M
i = 255*j/M
write(str,"(a,z6.6,a)") "%pl[colour=#", RGB@(255i,0,i), "]"
CALL winop@(trim(str))
ENDDO
i=winio@('%pl&',400,250,N,x,y)
i=winio@('%ff%nl%cn%tt[OK]')
END



Back to top 


DanRRight
Joined: 10 Mar 2008 Posts: 2684 Location: South Pole, Antarctica

Posted: Thu Mar 16, 2023 2:24 pm Post subject: 


Paul,
Thanks for an example. I tried before "stacked" option though some complexity stopped me. May be this was on my usual mischievous devilry saturdays and i may look again at that but first my questions:
1) if stacked can do 20 graphs why regular %pl can not? What the difference?
2) does stacked handle "independent" X and Y similarly easy? 

Back to top 


PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7584 Location: Salford, UK

Posted: Thu Mar 16, 2023 3:12 pm Post subject: 


1) Suffice to say that to provide the extension that you are asking for would not be quick and easy.
2) As I recall, only the Y values are stacked so you only get one set of X values. 

Back to top 


PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7584 Location: Salford, UK

Posted: Thu Mar 16, 2023 7:37 pm Post subject: 


I think that you could leave out [stacked] in the last sample above and present the data in a way that is not "stacked". The %pl line will have many arguments but you could, for example, use multiple Fortran continuation lines. 

Back to top 


DanRRight
Joined: 10 Mar 2008 Posts: 2684 Location: South Pole, Antarctica

Posted: Fri Mar 17, 2023 6:15 pm Post subject: 


Do i correctly understand that something like this should work ?
Code:  I=winio@('%pl[file=settings9.set, scale=linear, stacked,independent,n_graphs=9]', n, &
& x(:,1),y(:,1), x(:,2),y(:,2), x(:,3),y(:,3), x(:,4),y(:,4), &
& x(:,5),y(:,5), x(:,6),y(:,6), x(:,7),y(:,7), x(:,8),y(:,8), &
& x(:,9),y(:,9), x(:,10),y(:,10), x(:,11),y(:,11), x(:,12),y(:,12), &
& x(:,13),y(:,13), x(:,14),y(:,14), x(:,15),y(:,15), x(:,16),y(:,16), &
& x(:,17),y(:,17), x(:,18),y(:,18)......) 


Back to top 


PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7584 Location: Salford, UK

Posted: Fri Mar 17, 2023 7:51 pm Post subject: 


Yes. I am suggesting that it may well work but you still need
Code:  CALL winop@("%pl[n_graphs=20]") 
with 20 replaced by your value at the start. 

Back to top 


DanRRight
Joined: 10 Mar 2008 Posts: 2684 Location: South Pole, Antarctica

Posted: Fri Mar 17, 2023 9:48 pm Post subject: 


It only plots in my case 1 graph.
So i returned to your demo and made some changes.
Here is the same code above i modified (see arrows in the text), this unfortunately does not plot anything. For simplicity I made it to plot just two graphs. And also for simplicity i made number of points equal in both plots
Did i made a mistake or three? Clearly i did, as at least this method (stacked+independent) plots something in my larger code
Code:  WINAPP
USE clrwin
INTEGER M,N,i
PARAMETER(N=11,M=2) ! < changed M to 2
REAL*8 xm,x(N,M),y(N,M) !< changed X
INTEGER :: Np(M) ! < added Np
CHARACTER(len=24) str
! Replace this DO loop with data for each plot...
DO j=0,M1
DO i=1,N
xx = 0.1d0*(i1)
x(i,j+1) = xx
xm = 0.1d0
y(i,j+1) = xm*xx
xm = xm + 0.1d0
ENDDO
ENDDO
Np(:)=N ! < added
i=winio@("%ca[Multigraph]&")
CALL winop@("%pl[n_graphs=20]") !20=M
CALL winop@("%pl[stacked]")
CALL winop@("%pl[x_array]")
CALL winop@("%pl[x_max=1.0]")
CALL winop@("%pl[dx=0.1]")
CALL winop@("%pl[smoothing=4]")
CALL winop@("%pl[independent]") ! < added
!Various line colours going from blue to red...
DO j=1,M
i = 255*j/M
write(str,"(a,z6.6,a)") "%pl[colour=#", RGB@(255i,0,i), "]"
CALL winop@(trim(str))
ENDDO
i=winio@('%pl&',400,250,Np,x(:,1),y(:,1),x(:,2),y(:,2)) ! < changed
i=winio@('%ff%nl%cn%tt[OK]')
END 


Back to top 


PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7584 Location: Salford, UK

Posted: Fri Mar 17, 2023 10:28 pm Post subject: 


The number of graphs n_graphs is not 20 in your case. Also I suggested that you do not use [stacked]. The data presentation is probably wrong as well. That's all that I will contribute on this subject. 

Back to top 


DanRRight
Joined: 10 Mar 2008 Posts: 2684 Location: South Pole, Antarctica

Posted: Fri Mar 17, 2023 11:55 pm Post subject: 


Thanks for finding my bugs in these demos and discussion which may shed the light on limiting amount of plots %pl can do
Then here is my last question: does %pl have 9 graphs limit on standard way of plotting or it was lifted lately (we discussed to take off this limit couple years ago)?
May be somebody here will look at that and find something else i missed.
Conclusion is pretty strange so far:
1) Looks like with Stacked it complains and swearing but plots 12 graphs ( 6 of which upside down ? May be still some other mistake is still here)
2) But surprisingly without staked it somehow manages to plot 12 ...which indicates that my original program of this post made with the standard %pl method exactly like in the last demo (and which refused to plot more than 9 ) has some error (??).
I use latest compiler 8.95
Here is the final modified Paul's demo code which supposed not to work for more than 9 graphs (and it indeed does not for more than 9 in my larger code why i started this thread and i do there exactly like is shown here) but it somehow unexplainable works in this demo
Code:  WINAPP
USE clrwin
INTEGER M,N,i
PARAMETER(N=11,M=12)
REAL*8 xm,x(N,M),y(N,M) !< changed X
INTEGER :: Np(M) ! < added Np
CHARACTER(len=24) str
! Replace this DO loop with data for each plot...
DO j=0,M1 < changed a bit
xm = 0.1d0 * (j+1)
DO i=1,N
xx = 0.1d0*(i1)
x(i,j+1) = xx
y(i,j+1) = xm*xx
xm = xm + 0.1d0
ENDDO
ENDDO
Np(:)=N ! < added
i=winio@("%ca[Multigraph]&")
CALL winop@("%pl[n_graphs=12]")
! CALL winop@("%pl[stacked]")
CALL winop@("%pl[x_array]")
CALL winop@("%pl[x_max=1.0]")
CALL winop@("%pl[dx=0.1]")
CALL winop@("%pl[smoothing=4]")
CALL winop@("%pl[independent]") ! < added
!Various line colours going from blue to red...
DO j=1,M
i = 255*j/M
write(str,"(a,z6.6,a)") "%pl[colour=#", RGB@(255i,0,i), "]"
CALL winop@(trim(str))
ENDDO
i=winio@('%pl&',400,250,Np, x(:,1),y(:,1), x(:,2),y(:,2), x(:,3),y(:,3), x(:,4),y(:,4),&
& x(:,5),y(:,5), x(:,6),y(:,6), x(:,7),y(:,7), x(:,8),y(:,8), x(:,9),y(:,9), x(:,10),y(:,10),&
& x(:,11),y(:,11), x(:,12),y(:,12) )
i=winio@('%ff%nl%cn%tt[OK]')
END 


Back to top 


PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7584 Location: Salford, UK

Posted: Sat Mar 18, 2023 9:00 am Post subject: 


Yes you can have more than 10 plots (with or wihout [stacked]). Simply set n_graphs to the required number of graphs.
I have looked at the code for %pl and [stacked] with [independent] means both the x and the y arrays are stacked. But Dan, if you find [stacked] difficult to use why not go back to the old way of providing the data? 

Back to top 




You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum

Powered by phpBB © 2001, 2005 phpBB Group
