|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8037 Location: Salford, UK
|
Posted: Thu Oct 12, 2017 2:04 pm Post subject: |
|
|
Thanks Ken. I hope to come back to this thread when things are a little quieter. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 726 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Thu Oct 12, 2017 3:51 pm Post subject: |
|
|
John,
My quick and dirty fix for get_plot_point@ for log_log scales with logs using base 10.
Code: | module test
implicit none
integer, parameter, private :: dp = SELECTED_REAL_KIND(15,307)
integer, parameter, private :: npts = 5
real(kind=dp) :: x(1:npts) = (/0.1d0,1.d0,10.d0,100.d0,1000.d0/)
real(kind=dp) :: y(1:npts) = (/0.1d0,1.d0,10.d0,100.d0,1000.d0/)
integer margin, gw, gh !############
real(kind=dp) x_min, y_min, x_max, y_max !############
contains
integer function plot()
include<windows.ins>
integer i
i = winio@('%mn[Exit]&','exit')
i = winio@('%fn[Tahoma]&')
i = winio@('%ts&', 1.5d0)
call winop@('%pl[framed,etched]')
call winop@('%pl[x_array,N_GRAPHS=1]')
call winop@('%pl[margin=80]') !#########
margin = 80 !#########
call winop@('%pl[scale=log_log]')
call winop@('%pl[y_min=0.1,y_max=1000,x_min=0.1,x_max=1000]')
y_min = 0.1d0 !##########
y_max = 1000.d0 !##########
x_min = 0.1d0 !##########
x_max = 1000.d0 !##########
call winop@('%pl[link=lines, colour=blue, symbol=11, pen_style=0]')
i = winio@('%`bg[white]&')
gw = 800 !##########
gh = 600 !##########
i = winio@('%^pl',gw,gh,npts,x,y,call_back) !##########
plot=1
end function plot
integer function call_back()
include<windows.ins>
real(kind=dp) xx, yy
integer i
do i = 1, npts
call get_plot_point_k(x(i), y(i), xx, yy)
call draw_ellipse@(nint(xx),nint(yy),6,6,rgb@(0,0,0))
end do
call_back = 1
end function call_back
subroutine get_plot_point_k(x,y,xx,yy)
real(kind=dp), intent(in) :: x, y
real(kind=dp), intent(out) :: xx, yy
xx = log10(x) ; yy = log10(y)
xx = map_range(log10(x_min),log10(x_max),real(margin,kind=dp),real(gw-margin,kind=dp),xx)
yy = map_range(log10(y_min),log10(y_max),real(gh-margin,kind=dp),real(margin,kind=dp),yy)
end subroutine get_plot_point_k
real(kind=dp) function map_range(a1, a2, b1, b2, s)
real(kind=dp), intent(in) :: a1, a2, b1, b2, s
map_range = (s - a1) * (b2 - b1) / (a2 - a1) + b1
end function map_range
end module test
program main
use test
implicit none
integer i
i = plot()
end program main |
|
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 726 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Thu Oct 12, 2017 3:55 pm Post subject: |
|
|
and the corresponding plot
|
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 726 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Sun Oct 15, 2017 4:30 pm Post subject: |
|
|
John,
You can define the margins as integer variables and build up the pl string as follows before the final call to pl.
Code: | module pl_routines
implicit none
contains
subroutine set_pl_margins(top, bottom, left, right)
include<windows.ins>
integer, intent(in) :: top, bottom, left, right
character(len=5), parameter :: fmt1 = '(I5)'
character(len=5) t_txt, b_txt, l_txt, r_txt
character(len=12):: start_str = '%pl[margin=('
character(len=2 ):: end_str = ')]'
character(len=80) str
write(t_txt,fmt1) top ; write(b_txt,fmt1) bottom
write(l_txt,fmt1) left ; write(r_txt,fmt1) right
! Call to %pl[margin...] is left, top, right, bottom
str = start_str//trim(adjustl(l_txt))//','&
//trim(adjustl(t_txt))//','&
//trim(adjustl(r_txt))//','&
//trim(adjustl(b_txt))//end_str
write(6,*) str
call winop@(str)
end subroutine set_pl_margins
end module pl_routines
program test
use pl_routines
implicit none
include<windows.ins>
integer, parameter :: npts = 11
real(kind=2) x(1:npts), y(1:npts)
integer i, t, b, l, r
t = 200 ; b = 200 ; l = 100 ; r = 100
do i = 1,npts
x(i) = i-1
y(i) = (i-1)**2
end do
i = winio@('%mn[Exit]&','exit')
i = winio@('%fn[Tahoma]&')
i = winio@('%ts&', 1.5d0)
call winop@('%pl[native,x_array,N_GRAPHS=1]')
call winop@('%pl[y_min=0,y_max=100,x_min=0,x_max=10]')
call winop@('%pl[link=curves, colour=blue, symbol=11, pen_style=0]')
call set_pl_margins(t,b,l,r) !top, bottom, left, right
i = winio@('%`bg[white]&')
i = winio@('%pl',600,500,npts,x,y)
end program test
|
|
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Sun Oct 15, 2017 11:08 pm Post subject: |
|
|
Small change of subject. I have an idea how to plot full-colour area plots rather like Dan has asked for. The only thing that prevents this is that colours are defined by names. I need to be able to use RGB values (as obtained from function RGB@). This should really not be a major problem to implement ?
I would then divide the data set into multiple sets for different value ranges and plot each with a different colour. This would need more than the very limited set of named colours, to allow the use of a full colour palette.
Of course a much neater way to do this would be to allow a separate RGB value to be associated with each X,Y pair - i.e. each point would have its own colour, so we would have 3 arrays, X,Y, RGB. Any chance of doing this ? |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2877 Location: South Pole, Antarctica
|
Posted: Mon Oct 16, 2017 1:30 am Post subject: |
|
|
Silicondale, I agree, that would be good addition to Paul's reported concatenation few days back, I do not know how it was done but suspect this way
%pl(X,Y)
where X(i,j) and Y(i,j) are 2D arrays and number of plots j can be very large.
In this case adding color
%pl(X,Y,iColor)
besides expanding functionality of usual X-Y plotting will automatically turn native %pl into 2D surface plotter. But suspect this stuff will be for the future, after our usual 1D X-Y plots will be made perfect
Last edited by DanRRight on Mon Oct 16, 2017 7:46 am; edited 1 time in total |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2877 Location: South Pole, Antarctica
|
Posted: Mon Oct 16, 2017 4:56 am Post subject: |
|
|
Ken,
I think silicondale got with your example problem with resizing.
To do resize just add %ww%pv to %pl'
Code: | i = winio@('%ww%pv%pl%es',600,500,npts,x,y) |
By some reason resizing does not work if %ww is absent. In many other cases %ww indeed is redundant (unless this is not some Clearwin bug and %ww must be always present)
In my turn I have difficulty compiling your latest posted codes because always have error
' PROCESSING MODULE [<PL_ROUTINES> FTN95/Win32 v8.10.0]
*** This statement contains an illegal character - '�''
*** This statement contains an illegal character - '�''
*** This statement contains an illegal character - '�''
Is this some kind of a celtic space of some UTF8 character coding ? . Removing all spaces solves the problem.
Do others also have similar problems? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8037 Location: Salford, UK
|
Posted: Mon Oct 16, 2017 7:35 am Post subject: |
|
|
Silicondale
I am not sure if this is what you need but you can set the colour via
call winopt@("%pl[colour=#bbggrr]")
where bb is the hex value for the blue component etc.
For example:
call winopt@("%pl[colour=#FF0000]")
for blue etc.
It's a little more tricky if the colour is "dynamic". For example if the colour has components R,G,B then you would need something like...
Code: | write(str,"(a,z6.6,a)") "%pl[colour=#", RGB@(B,G,R), "]"
CALL winop@(trim(str))
|
because we need the reverse order to that given by RGB@.
p.s. This post is incorrect. See new post in this thread.
Last edited by PaulLaidler on Mon Nov 06, 2017 4:27 pm; edited 1 time in total |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Mon Oct 16, 2017 8:01 am Post subject: |
|
|
Paul - many thanks for that. Certainly goes some of the way towards what we need, especially your 'dynamic colour' workaround. Ideally we should be able to attach a different colour to each individual point, but this is certainly a start. Could of course split the data into thousands of separate one-element arrays each with its own colour, but that wouldn't really be workable with %pl as it is!
By the way, I have been using winop@ but this is the first time I have seen winopt@ - can you point me to any documentation, please?
Odd that you use #bbggrr - the standard that I think is more commonly used (such as in HTML coding, for example) is #rrggbb |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8037 Location: Salford, UK
|
Posted: Mon Oct 16, 2017 8:57 am Post subject: |
|
|
winopt@ was just my typing error. It should be winop@.
I am guessing that #bbggrr is somebody's standard. Is it not HTML? |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Mon Oct 16, 2017 10:38 am Post subject: |
|
|
Paul - many thanks. yes, I saw your example was winop@ so realised (after posting) that it was just a mistype.
HTML standard is #rrggbb -- see https://www.w3schools.com/colors/default.asp for details.
Maybe I'm misunderstanding something, but the RGB@ documentation (in the FTN95 help file) has the arguments in the order RED GREEN BLUE. I supply values Red=127 Green=0 and Blue=0 which should give a dark red colour. The RGB@ function gives value 127 or Hex 00007F - which is dark blue.
However if I supply Red=0 Green=0 Blue=127 which should give dark blue, the RGB@(0,0,127) = 8323072 = Hex 7F0000 = dark red.
Not sure what is going on here! Maybe generation of the Hex #rrggbb colour code should not just be using the Z6.6 format but should take each byte separately in the order R, G, B - probably easiest to do by avoiding RGB@ altogether but using the red, greem, and blue separately.
This works correctly:
Code: |
write(pltext,"(a,3z2.2,a)") '%pl[colour=#', ir,ig,ib, ']'
call winop@(trim(pltext))
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8037 Location: Salford, UK
|
Posted: Mon Oct 16, 2017 11:25 am Post subject: |
|
|
It's just that RGB@ gives the wrong order for this context so you have to use it in an unnatural way (i.e. we need a BGR@ function at this point).
Anyway, your approach is better. |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Mon Oct 16, 2017 1:04 pm Post subject: |
|
|
Here is a simple demo of surface display using %pl, that Dan wanted to achieve. Using 4 arrays for different data value ranges, with different colours, small filled square symbols. Could generalise this, but stuck with limitation of 10 arrays - and messy coding as we need to hold the data in 10 separate sets of x,y arrays instead of a single set and a colour-code array.
This is what I would like to achieve (and I suspect a bit closer to what Dan wants), with an unlimited number of different colours.
For that, we would need to be able to supply x,y,rgb arrays to %pl, not just x,y[/img] |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 726 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Mon Oct 16, 2017 1:26 pm Post subject: |
|
|
Silicondale, Paul did say in an earlier post that the limit on the number of plots (10) has been removed, so when the next DLL comes out you will be able to expand on your 1st 2-d plot. We'll also get grid lines then |
|
Back to top |
|
|
silicondale
Joined: 15 Mar 2007 Posts: 252 Location: Matlock, Derbyshire, UK
|
Posted: Mon Oct 16, 2017 1:36 pm Post subject: |
|
|
Thanks, Ken - I missed that one! That is good news.
What I shall need to do now is work out how to tidy up the coding - and add a colour palette to the side of the plot. Adding a general feature such as copying and pasting a graphics region on to the plot could allow that!
Fortunately for most of what I need, I don't have to go into the complexities of log-log plots, etc!
..... a little later .....
OK, have now hit limit of N-GRAPHS (tried 16, doesn't work. 10 works). Have also added a colour ramp.
Just a couple of problems with this.
(1) the y axis annotation doesn't appear. Since I can't see it anywhere (I tried a wider margin but that didn't help) I can't move it to somewhere visible.
(2) I'd like to be able to put the colour ramp into one of the margins, so it will get saved in any exported jpg or png file - but can't find any way to do this. |
|
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
|