forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Can Native PL do this?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sat Mar 20, 2021 8:19 am    Post subject: Can Native PL do this? Reply with quote

With the new option of histogram plotting recently added can the new %PL do candles like here?

The link=columns which is doing this seems plots columns from zero, not from arbitrary min value to arbitrary max value. And also can it do that of different colors? Plus can we add the lines on top and bottom of columns? Plus change the column width?



Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Sat Mar 20, 2021 11:38 am    Post subject: Reply with quote

No Dan, candles in the air takes magic - you obviously didn't attend Hogwarts School ....
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Sat Mar 20, 2021 11:43 am    Post subject: Reply with quote

Dan

%pl does not do this for you but you can do it yourself from a %pl callback function and callback reason "PLOT_ADJUST".

You could call get_plot_point@ and then draw your own symbols using draw_filled_rectangleD@ etc..
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



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

PostPosted: Sat Mar 20, 2021 5:11 pm    Post subject: Reply with quote

Dan,
This is the closest I can get to your requirements without resorting to drawing on the %pl via the call back. I thought it was going to be easy, but I had forgotten that %pl[width] applies to ALL graphs.
Ken
Code:
winapp
module dan_mod
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0)
integer, parameter :: n_candles = 20
real(kind=dp) x(1:n_candles), y_min(1:n_candles), y_low(1:n_candles), y_high(1:n_candles), y_max(1:n_candles)
integer n_graphs
integer,       allocatable :: n_points(:)
real(kind=dp), allocatable :: x_pl(:), y_pl(:)

contains
  integer function create_data()
  integer i
    do i = 1, n_candles
      x(i) = i
      y_max(i)  = 100       * random@()
      y_high(i) = y_max(i)  * random@()
      y_low(i)  = y_high(i) * random@()
      y_min(i)  = y_low(i)  * random@()
      print '(I4,1X,4(F6.3,1X))', i, y_max(i), y_high(i), y_low(i), y_min(i)
    end do
    create_data = 1
  end function create_data

  integer function plot_data()
  integer i, j, counter
  integer iw
  character(len=128) pl_str
    n_graphs = 2*n_candles
    allocate( n_points(1:n_graphs) ) ; n_points = 2
    allocate( x_pl(4*n_candles), y_pl(4*n_candles) )
    counter = 1
    do j = 1, n_candles, 1
      do i = 1, 4, 1
        x_pl(counter) = x(j)
        counter = counter + 1
      end do
    end do
    counter = 1
    do j = 1, n_candles, 1
        y_pl(counter)     = y_min(j)
        y_pl(counter + 1) = y_max(j)
        y_pl(counter + 2) = y_low(j)
        y_pl(counter + 3) = y_high(j)
        counter = counter + 4
    end do
    iw = winio@('%mn[Exit]&','exit')
    iw = winio@('%fn[Consolas]&')
    iw = winio@('%ts%bf&',1.5d0)
    write(pl_str,'("%pl[native,stacked,n_graphs=",I4,"]")') n_graphs !  ; print*, pl_str
    call winop@(pl_str)
    call winop@('%pl[x_array, independent, frame, gridlines]')
    do i = 1, n_candles
       call winop@('%pl[link=lines,width=1,colour=blue,pen_style=2]')   !Does not work as written since width applies to all graphs
       call winop@('%pl[link=lines,width=5,colour=red, pen_style=0]')   !Changed pen_style as alternative
    end do
    iw = winio@('%pl&',900,600,n_points,x_pl,y_pl)   
    iw = winio@(' ')
    plot_data = 1
  end function plot_data
end module dan_mod

program main
use dan_mod
implicit none
integer i
  i = create_data()
  i = plot_data()
end program main
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



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

PostPosted: Sat Mar 20, 2021 5:38 pm    Post subject: Reply with quote

Or perhaps this ?

Code:
winapp
module dan_mod
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0)
integer, parameter :: n_candles = 20
real(kind=dp) x(1:n_candles), y_min(1:n_candles), y_low(1:n_candles), y_high(1:n_candles), y_max(1:n_candles)
integer n_graphs
integer,       allocatable :: n_points(:)
real(kind=dp), allocatable :: x_pl(:), y_pl(:)

contains
  integer function create_data()
  integer i
    do i = 1, n_candles
      x(i) = i
      y_max(i)  = 100       * random@()
      y_high(i) = y_max(i)  * random@()
      y_low(i)  = y_high(i) * random@()
      y_min(i)  = y_low(i)  * random@()
      print '(I4,1X,4(F6.3,1X))', i, y_max(i), y_high(i), y_low(i), y_min(i)
    end do
    create_data = 1
  end function create_data

  integer function plot_data()
  integer i, j, counter
  integer iw
  character(len=128) pl_str
    n_graphs = 2*n_candles
    allocate( n_points(1:n_graphs) ) ; n_points = 2
    allocate( x_pl(4*n_candles), y_pl(4*n_candles) )
    counter = 1
    do j = 1, n_candles, 1
      do i = 1, 4, 1
        x_pl(counter) = x(j)
        counter = counter + 1
      end do
    end do
    counter = 1
    do j = 1, n_candles, 1
        y_pl(counter)     = y_min(j)
        y_pl(counter + 1) = y_max(j)
        y_pl(counter + 2) = y_low(j)
        y_pl(counter + 3) = y_high(j)
        counter = counter + 4
    end do
    iw = winio@('%mn[Exit]&','exit')
    iw = winio@('%fn[Consolas]&')
    iw = winio@('%ts%bf&',1.5d0)
    write(pl_str,'("%pl[native,stacked,n_graphs=",I4,"]")') n_graphs
    call winop@(pl_str)
    call winop@('%pl[x_array, independent, frame, gridlines, width=4]')
    do i = 1, n_candles
       call winop@('%pl[link=lines,colour=blue,symbol=0]')
       call winop@('%pl[link=lines,colour=red, symbol=6]')
    end do
    iw = winio@('%pl&',900,600,n_points,x_pl,y_pl)   
    iw = winio@(' ')
    plot_data = 1
  end function plot_data
end module dan_mod

program main
use dan_mod
implicit none
integer i
  i = create_data()
  i = plot_data()
end program main
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



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

PostPosted: Sat Mar 20, 2021 10:25 pm    Post subject: Reply with quote

Paul,

The examples I posted today in response to Dan’s question “Can Native PL do this?” are based on using the %pl[stacked] option, and representing each candle by two line elements.

This work for n_candles up to 128, where n_graphs in the %pl region reaches 256.

For larger values of n_candles, the code fails as it appears that winop@(‘%pl[colour=red]’) etc can only process the colour/symbol etc instructions for the first 256 graphs.

This is most clearly demonstrated using the second example and setting the integer parameter n_candles = 256, which means n_graphs = 512. When the %pl is drawn, all specified colour and symbol data for the graphs with IDs 257 to 512 is absent.

So although the stacked option has no restriction on n_graphs, calling winop@ is restricted to setting graph parameters for just the first 256 graphs.

CHANGE_PLOT_INT@ etc can be used after the window is formed to change the appearance of the graphs with ids 257 to 512.

Ken
Back to top
View user's profile Send private message Visit poster's website
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Sun Mar 21, 2021 8:16 am    Post subject: Reply with quote

Thanks Paul and Ken for suggestions and examples which save my time for experimenting.
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Sun Mar 21, 2021 10:06 pm    Post subject: Reply with quote

if th Bears are exhausted and the Bulls also at the same time does that mean there's inevitable overtime in Chicago ?
... even though their balls are different shapes Smile
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Mar 22, 2021 9:59 am    Post subject: Reply with quote

Ken

At the moment I can't see the restriction in the ClearWin+ code.

Do you have a short sample that illustrates the failure?
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



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

PostPosted: Mon Mar 22, 2021 2:02 pm    Post subject: Reply with quote

Paul,

In this example there are 512 graphs, each containing a single point.
When I run the code only the first 256 graphs (i.e. symbols) are displayed.

Although
Code:
call winop@('%pl[link=none, colour=red,  symbol=6]'

is called 512 times.

Code:
winapp
module paul_mod
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0)
integer, parameter :: ngraph_max = 512
integer :: n_points(1:ngraph_max) = 1
real(kind=dp):: x_pl(ngraph_max), y_pl(ngraph_max)

contains

integer function create_data()
integer i
  do i = 1, ngraph_max, 1
    x_pl(i)=i
    y_pl(i)=i
  end do
create_data = 2
end function create_data

integer function plot_data()
  integer i
  integer iw
  character(len=128) pl_str 

  write(pl_str,'("%pl[native,stacked,n_graphs=",I4,"]")') ngraph_max
  call winop@(pl_str)
  call winop@('%pl[x_array, independent, frame, etched, gridlines, width=4]')
  do i = 1, ngraph_max
    call winop@('%pl[link=none, colour=red,  symbol=6]')
    print*, i, x_pl(i), y_pl(i)
  end do
  iw = winio@('%pl&',900,600,n_points,x_pl,y_pl)
  iw = winio@('%ff%cn%bt[OK]&')
  iw = winio@('')
  plot_data = 2
end function plot_data

end module paul_mod

program main
use paul_mod
implicit none
integer i
  i = create_data()
  i = plot_data()
end program main


Here is a screenshot of what I see:

https://www.dropbox.com/s/hj1ov3w6zrfsl2p/pl_stacked.jpg?dl=0
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Mar 22, 2021 3:51 pm    Post subject: Reply with quote

Ken

I have fixed this and will send you a new set of DLLs shortly.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



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

PostPosted: Tue Mar 23, 2021 1:05 pm    Post subject: Reply with quote

Paul,

Thanks, I can see that it is fixed with the new DLLs.

And thanks to Dan for the "candle challenge" which identified the previous restriction.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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