Silverfrost Forums

Welcome to our forums

Native %pl

13 Mar 2017 11:40 #19097

Here is a link to a new set of DLLs. Don't forget to backup the original DLLs before replacing with the new ones.

https://www.dropbox.com/s/93ikhswrxul5bjn/newDLLs4.zip?dl=0

13 Mar 2017 6:34 #19101

Excellent Paul, Thank you for that. No overshoot in either of these curves now.

http://tr5mx.co.uk/example2.jpg

Dan, this code generated the plot above and points the way for multiple plots.

program step
implicit none
include<windows.ins>
integer i
real(kind=2), dimension(1:1000) :: time_plot, volt_plot, amps_plot
real(kind=2) delta_t, time

delta_t = 0.001d0
time = 0.d0

do i = 1, 1000
 time_plot(i) = time
 if (time .lt. 0.5d0) then
   volt_plot(i) = 0.d0
 else
   volt_plot(i) = 1.d0
 end if
 if (time .lt. 0.25d0) then
   amps_plot(i) = 0.d0
 else
   amps_plot(i) = exp(-time/0.5d0)
 end if
 time = time+delta_t
end do

i = winio@('%ww&')
CALL winop@('%pl[native]')
call winop@('%pl[x_array]')
call winop@('%pl[n_graphs=2]')
call winop@('%pl[link=lines]')
call winop@('%pl[x_axis='Time [s]']')
call winop@('%pl[y_axis='V [pu], I [pu]']')
call winop@('%pl[y_min=0.d0]')
call winop@('%pl[y_max=1.1d0]')
call winop@('%pl[dy=0.2d0]')
call winop@('%pl[width=2]')
call winop@('%pl[colour=red,colour=blue]')
i = winio@('%pl',400,400, 1000, time_plot, volt_plot, amps_plot)
        
end program step

Regards

Ken

13 Mar 2017 6:46 #19102

Dan, Just read your question again.

You need to add

call winop@('%pl[framed]')

before the winio call to %pl in the example code to get the box.

Ken

13 Mar 2017 7:32 #19103

Thanks, great that we start getting first Pros here in plotting subject. Can new %p nowl set the frame line width, curves line width and font width for caption and axis all individually?

14 Mar 2017 10:09 #19111

John

There is a readme.txt in the download and, yes, the fixes are cumulative.

The initial aim was to replicate the ClearWin+ interface to SIMPLEPLOT and (apart from the odd fix) I think that has been achieved and more (log scaling has now been implemented but this feature has not yet been released).

There are no plans to go further with %pl. When we come back to this subject we will take a fresh look and maybe use a different approach to providing easy graphs.

I understand that this may be a disappointment but the subject is endless and we need to find a way to tap into existing code rather than write our own.

Don't forget to take a look at SIMDEM as an alternative.

15 Mar 2017 8:44 #19120

Look at these SIMDEM demos. I am surprised that their authors do not care what they show to the public if they want that their software was used.

http://www.simfit.org.uk/examples.html

All looks like plot demos were made on old DOS screens in 1993... no, 1987, with x-y plots quality being just a bit better then old ugly Simpleplot. None is suitable to any journal in the world. Add such bar chart into your grant solicitation and you'll probably loose. Make advertisements of your company with these 3D plots and all will laugh. May be these plots can be done much better but we have to see that in their ad, otherwise the first reaction is: old and ugly. Also look at their Fortran source codes of hundreds lines long. That is completely different ideology then we demand for %pl.

The new %pl already made a lot of improvement over Simpleplot and adding just few minor things may approach the ability to generate the production quality plots and ultimate ease at the same time.

In this case it may compete with MATLAB quality and simplicity plotting many use directly for major journals. This quality and being easy are key factors why people leave Fortran in favor of MATLAB. The new %pl has just to be customizable. Ideally it has to allow to gather all these numerous 'call winop@' settings into one single line like 'my_settings_1' to plot the production quality plots in one single line.

15 Mar 2017 10:03 #19122

Dan,

This works as well - personally I prefer separate lines to make the code more readable.

 CALL winop@('%pl[native,x_array,n_graphs=2,link=lines,x_axis='Time [s]']') 
 call winop@('%pl[y_axis='V [pu], I [pu]',y_min=0.d0,y_max=1.1d0,dy=0.2d0,width=2,colour=red,colour=blue]') 

Regards

Ken

[/code]

15 Mar 2017 10:55 #19124

That how I used older Simpleplot. I used character*320 variable for that. Look at this monstrosity which I expanded by photoshopping because it did not fit

https://s1.postimg.org/tqitzw533/320char.jpg

But may be better would be to offer one settings for all that and the icon in the corner of the plot where you can click and all settings will be displayed and changed dynamically. This is because new %pl offers more options to customize plot. And will inevitably offer even more in the future

15 Mar 2017 11:13 #19125

John

I will aim to provide an upload within a week.

15 Mar 2017 11:52 #19128

John, I didn't realise you could use HEX codes (#339900) for the colours in %pl. That opens up more possibilities 😄 Thanks Ken

16 Mar 2017 7:45 #19137

Noticed that I call the plot with one single line of Fortran source like this

call winop@(charvar, N, ix,iy, X, Y1, Y2, Y3, Y4, Y5, Y6)

to plot up to 6 curves dynamically - and not as if it was programmed ones for one case and you can not change anything without recompilation? This is because you can edit charvar in this window, showed in the previous post, you can update the plot the way you want dynamically. This charvar contain all the settings for the plot, and it is saved into the file each time you plot, so next time you just call the program and the plot looks perfect as you left it.

If I was not clear in previous message what I suggest to Silverfrost to think about to get ultimate easiness for the new %pl here is the picture which is as usually better then 100 words : if place the icon in the corner (marked as #1), and when the changes of the graph will be needed invoke it with right mouse. There is menu for better looking settings then the one single long heap of all things in charvar.

https://s24.postimg.org/uu4q032xh/new_Pl_Icon2.jpg

This is how OriginLab is doing that

16 Mar 2017 8:21 #19138

Dan

Thanks for the feedback but there are no plans to do further work on the native %pl.

If you find any bugs then please let me know.

16 Mar 2017 12:08 #19146

I did not test native â„…pl yet but hope with last release some obvious defects we discussed before were fixed (if first user already said 'the new %pl is really good'. Litle bit more polishing and all will say 'i love it' ).

One of such i'd say 'bugs' was the axis and tic marks linewidth which was just single pixel wide. Ideally would be to make separate option for axis linewidth and curves linewidth not just one single linewidth parameter for both curves and axis like in older Simpleplot's â„…pl. That control over small details in grapgics looks like minor unimportant matter but it is exactly what distinguish beauty and ugliness. Beauty is skin deep (and ugly down to the bones)

17 Mar 2017 12:07 #19157

Using %pl I can get the handle of the graphics region created by %pl, so I should be able to create a graphics region in memory into which I can copy four separate %pl graphic areas and export them as a single image.

The following code does this, and creates an image as required. However then the user selects exit, an access violation occurs. I've hit a bit of brick wall over the last few days on this. Is there anything obviously wrong in the code?

Thanks

Ken

module plot_mod
implicit none
integer, parameter :: npts = 100
integer, parameter :: hand_p1 = 1, hand_p2 = 2, hand_p3 = 3, hand_p4 = 4, hand_p5 = 5
integer, parameter :: gw = 300, gh = 250 
real(kind=2) time(1:npts), s1(1:npts), s2(1:npts), s3(1:npts), s4(1:npts)
contains

  integer function generate_time_series()
    real(kind=2) t, dt, omega
    integer i
    t = 0.d0 ; dt = 0.001d0 ; omega = 2.d0*4.d0*(atan(1.d0))*50.d0
    do i = 1, npts, 1
      time(i)=t ; s1(i)=sin(omega*t) ; s2(i)=cos(omega*t) ; s3(i)=s1(i)+s2(i) ; s4(i)=s3(i)*s3(i) ;t=t+dt
    end do
    generate_time_series = 1
  end function generate_time_series

  integer function plot_time_series()
  include<windows.ins>
  integer i
    i = winio@('%ww&')
    i = winio@('%mn[Close]&','EXIT')
    i = winio@('%mn[Save_plot]&',save_plot_cb)
    call winop@('%pl[native]')
    call winop@('%pl[x_array]')
    call winop@('%pl[COLOUR=RED]')
    call winop@('%pl[smoothing=4]')
    i = winio@('%`pl&',gw,gh,npts,time,s1, hand_p1)
    call winop@('%pl[native]')
    call winop@('%pl[x_array]')
    call winop@('%pl[COLOUR=blue]')
    call winop@('%pl[smoothing=4]')
    i = winio@('%`pl&',gw,gh,npts,time,s2, hand_p2)
    i = winio@('%ff&')
    call winop@('%pl[native]')
    call winop@('%pl[x_array]')
    call winop@('%pl[COLOUR=green]')
    call winop@('%pl[smoothing=4]')
    i = winio@('%`pl&',gw,gh,npts,time,s3, hand_p3)
    call winop@('%pl[native]')
    call winop@('%pl[x_array]')
    call winop@('%pl[COLOUR=black]')
    call winop@('%pl[smoothing=4]')
    i = winio@('%`pl',gw,gh,npts,time,s4, hand_p4)
    plot_time_series = 1
  end function plot_time_series
17 Mar 2017 12:08 #19158

second part

  integer function save_plot_cb()
  include<windows.ins>
  integer i, create_graphics_region@, copy_graphics_region@, select_graphics_object@, export_image@, &
             delete_graphics_region@
    i = create_graphics_region@(hand_p5, gw*2, gh*2) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, 0,   0, gw, gh, hand_p1, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, gw,  0, gw, gh, hand_p2, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, 0,  gh, gw, gh, hand_p3, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, gw, gh, gw, gh, hand_p4, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = select_graphics_object@(hand_p5) ; write(6,*) i
    i = export_image@('picture.jpg')     ; write(6,*) i
    i = delete_graphics_region@(hand_p5) ; write(6,*) i
    save_plot_cb = 1
  end function save_plot_cb
end module plot_mod

program main
use plot_mod
implicit none
integer i
i = generate_time_series()
i = plot_time_series()
end program main
17 Mar 2017 12:10 #19159

And the problem:-

http://tr5mx.co.uk/problem.jpg

17 Mar 2017 12:54 #19160

A little bit more to the tale. If I have four graphics regions created using %`gr, it works fine as the following shows:-

module plot_mod
implicit none
integer, parameter :: hand_p1 = 1, hand_p2 = 2, hand_p3 = 3, hand_p4 = 4, hand_p5 = 5
integer, parameter :: gw = 300, gh = 250 

contains

  integer function plot()
  include<windows.ins>
  integer i
    i = winio@('%ww&')
    i = winio@('%mn[Close]&','EXIT')
    i = winio@('%mn[Save_plot]&',save_plot_cb)
    i = winio@('%`gr&',gw,gh, hand_p1)
    call draw_filled_rectangle@(0,0,gw,gh,rgb@(255,0,0))
    i = winio@('%`gr&',gw,gh, hand_p2)
    call draw_filled_rectangle@(0,0,gw,gh,rgb@(0,255,0))
    i = winio@('%ff&')
    i = winio@('%`gr&',gw,gh, hand_p3)
    call draw_filled_rectangle@(0,0,gw,gh,rgb@(0,0,255))
    i = winio@('%`gr&',gw,gh,  hand_p4)
    call draw_filled_rectangle@(0,0,gw,gh,rgb@(101,156,239))
    i = winio@('%ws',' ')
    plot = 1
  end function plot

  integer function save_plot_cb()
  include<windows.ins>
  integer i, create_graphics_region@, copy_graphics_region@, select_graphics_object@, export_image@, &
             delete_graphics_region@
    i = create_graphics_region@(hand_p5, gw*2, gh*2) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, 0,   0, gw, gh, hand_p1, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, gw,  0, gw, gh, hand_p2, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, 0,  gh, gw, gh, hand_p3, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = copy_graphics_region@(hand_p5, gw, gh, gw, gh, hand_p4, 0, 0, gw, gh, srccopy ) ; write(6,*) i
    i = select_graphics_object@(hand_p5) ; write(6,*) i
    i = export_image@('picture.jpg')     ; write(6,*) i
    i = delete_graphics_region@(hand_p5) ; write(6,*) i
    save_plot_cb = 1
  end function save_plot_cb
end module plot_mod

program main
use plot_mod
implicit none
integer i
i = plot()
end program main
17 Mar 2017 5:11 #19164

Yes you can plot more than one graph but the access violation appears to be a bug in ClearWin+ that needs fixing.

17 Mar 2017 7:08 #19166

Thanks Paul, I will stop pursuing this for now and just export data as a CSV for import to excel for plotting.

I did try a slightly different approach, replacing the save_plot_cb function in my first post with the following which does not call copy_graphics_region@.

Unfortunately, the error still occurs.

  integer function save_plot_cb()
  include<windows.ins>
  integer i, create_graphics_region@, select_graphics_object@, export_image@, import_image@, &
             delete_graphics_region@
  real(kind=2) set_jpeg_quality@
  integer(kind =2) error_code
     i = set_jpeg_quality@(1.d0)
     i = select_graphics_object@(hand_p1) ; write(6,*) i
     i = export_image@('picture01.jpg')   ; write(6,*) i
     i = select_graphics_object@(hand_p2) ; write(6,*) i
     i = export_image@('picture02.jpg')   ; write(6,*) i
     i = select_graphics_object@(hand_p3) ; write(6,*) i
     i = export_image@('picture03.jpg')   ; write(6,*) i
     i = select_graphics_object@(hand_p4) ; write(6,*) i
     i = export_image@('picture04.jpg')   ; write(6,*) i
     i = create_graphics_region@(hand_p5, gw*2, gh*2) ; write(6,*) i
     i = select_graphics_object@(hand_p5) ; write(6,*) i
     i = import_image@('{picture01.jpg}',0,0)   ; write(6,*) i
     i = import_image@('{picture02.jpg}',gw,0)  ; write(6,*) i
     i = import_image@('{picture03.jpg}',0,gh)  ; write(6,*) i
     i = import_image@('{picture04.jpg}',gw,gh) ; write(6,*) i
     i = export_image@('picture.jpg')           ; write(6,*) I
     i = delete_graphics_region@(hand_p5) ; write(6,*) i
     call erase@('picture01.jpg',error_code)
     call erase@('picture02.jpg',error_code)
     call erase@('picture03.jpg',error_code)
     call erase@('picture04.jpg',error_code)
    save_plot_cb = 1
  end function save_plot_cb
18 Mar 2017 3:04 #19174

Kenneth

This has now been fixed and a new set of DLLs will be available shortly.

Please login to reply.