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 

Limitation of number of plots in %PL
Goto page Previous  1, 2, 3  Next
 
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: Tue Oct 12, 2021 9:11 pm    Post subject: Reply with quote

Yes, Ken, they are in correct order, the last color is red, not blue. Same colors then were taken for the legend with numbers at the right. Looks like this is the second bug here besides the one which did not allow >10 plots. WE NEED MORE USERS of %PL. This way such bugs will be revealed quicker.

/* I do not understand why people using this compiler do not use the unique opportunity that the same company which makes them compiler makes also the graphics and GUI too. If all 3 were different pieces software from 3 different vendors the chance users code will disintegrate over a decade, maximum two would be almost 100%. Clearwin, its graphics, and OpenGL are working for all other Fortran compilers now, so the bet on using them is safest ever
Back to top
View user's profile Send private message
Kenneth_Smith



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

PostPosted: Tue Oct 19, 2021 7:59 pm    Post subject: Reply with quote

Dan wrote
Quote:
the last color is red, not blue.


Can you show us how you converted the (r,g,b) triplet to hex?

Or try using this approach:

Code:
module dan_test_mod
use clrwin
implicit none
integer, parameter :: dp = kind(1.d0)

contains

integer function start()
integer iw, i
real(dp) x1(2), y1(2)
character(len=19) str
integer :: np = 2

  x1 = [0,1]
  y1 = [0,1]
 
  iw = winio@('%mn[Exit]&','exit')
  call winop@('%pl[n_graphs=1]')
  call winop@('%pl[x_axis="x"]')
  call winop@('%pl[y_axis="y"]')
  call winop@('%pl[x_array,independent,frame,width=2]')
 
  str = plcolour(255,0,0)
 
  print*, str
  call winop@(str)

  call winio@('%pl',400,400,2,x1,y1)
start = 1
end function start

character(len=19) function plcolour(r,g,b)
integer r,g,b
character(len=12), parameter :: start_str = "%pl[colour=#"
character(len=1),  parameter :: end_str = "]"
character(len=2)   red, green, blue
  write(red,   '(z2.2)') r
  write(green, '(z2.2)') g
  write(blue,  '(z2.2)') b
plcolour = start_str//red//green//blue//end_str
end function plcolour

end module dan_test_mod

program main
use dan_test_mod
implicit none
integer i
i = start()
end program main
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: Wed Oct 20, 2021 4:56 am    Post subject: Reply with quote

Ken, Thanks for attention to this issue
Here is my way of assigning colors.

Code:

!... 1) here data was prepared for time moments it = 1,2,3,...,23
!       Xmp(:,1), Ymp(:,1)
!       Xmp(:,2), Ymp(:,2)
!      ....................
!       Xmp(:,23), Ymp(:,23)
!
!   2) Then colors are assigned for these time moments

DO it = 1, 23
!.................................................
! here 23 times ir111,ig111,ib111 are prepared by some rule
!.................................................
! 3) here they are used

  iCol_MplotPL(it) = rgb@(ir111,ig111,ib111)

  write(SomeplotText1,"(a,z6.6,a)") '%pl[colour=#', rgb@(ir111,ig111,ib111), ']'
  write(ColorsMplot2(i),"(a,z6.6,a)") '#', rgb@(ir111,ig111,ib111)

!.. here these colors are assigned to %PL
  CALL winop@(trim(SomeplotText1))

  enddo

!... 4) here we check if 23 colors are following palette order from violet to red? ?
  write(*,*) ColorsMplot2


endDO ! DO it = 1, 23

!...5) Here we call %PL

   i=winio@('%pv%^pl[frame,framed,axes_pen=3,frame_pen=3,etched,'//
     *   'width=2,x_array,independent]%ff&',
     *  lenXScrSize_MplotPL, lenYScrSize_MplotPL, Np,
     *  Xmp(1,1), Ymp(1,1), Xmp(1,2), Ymp(1,2), Xmp(1,3), Ymp(1,3),
     *  Xmp(1,4), Ymp(1,4), Xmp(1,5), Ymp(1,5), Xmp(1,6), Ymp(1,6),
     *  Xmp(1,7), Ymp(1,7), Xmp(1,8), Ymp(1,8), Xmp(1,9), Ymp(1,9),
     *  Xmp(1,10),Ymp(1,10),Xmp(1,11),Ymp(1,11),Xmp(1,12),Ymp(1,12),
     *  Xmp(1,13),Ymp(1,13),Xmp(1,14),Ymp(1,14),Xmp(1,15),Ymp(1,15),
     *  Xmp(1,16),Ymp(1,16),Xmp(1,17),Ymp(1,17),Xmp(1,18),Ymp(1,18),
     *  Xmp(1,19),Ymp(1,19),Xmp(1,20),Ymp(1,20),Xmp(1,21),Ymp(1,21),
     *  Xmp(1,22),Ymp(1,22),Xmp(1,23),Ymp(1,23), cb2MultiplotPL)



!...6) Here is cb2MultiplotPL where we plot colors



idShiftTimesMesh = 18    ! vertical spacing between time numbers
ixShiftTimesMesh = 150  ! shift time numbers to the right
iyShiftTimesMesh = 650  ! shift time numbers up/down

       do it=1,23

       CALL draw_line_betweenD@(
     *        1d0+ixShiftTimesMesh+idx,
     *        iyShiftTimesMesh + it*idShiftTimesMesh+1d0,
     *        20d0+ixShiftTimesMesh+idx,
     *        iyShiftTimesMesh + it*idShiftTimesMesh+1d0,
!      *       iCol_MplotPL(it) ) --> in such order or in next line another
     *        iCol_MplotPL(23-it+1) )

   write(SomeplotText1,'(f7.0)') TimeActual(it)*1000.
        CALL draw_charactersD@(trim(SomeplotText1),
     *  30.d0+ixShiftTimesMesh+idx,
     *  iyShiftTimesMesh + it*idShiftTimesMesh+13.d0, 0)   
       enddo   



Will tell about even more strange devilry thing. As you saw above I tried to generate regular solar spectrum color palette from violet to red (or red to violet, it does not matter). If my colors started from violet and go to red then all is messed up like was shown above in that post a week ago. But if i omit violet and start colors with blue and they go to red then all works without issues.
Back to top
View user's profile Send private message
Kenneth_Smith



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

PostPosted: Wed Oct 20, 2021 2:02 pm    Post subject: Reply with quote

Dan,

This demonstrates where I think the issue may be:

Code:
character(len=19) str1, str2
print*
print*, 'cyan   is rgb(0,255,255) which is HEX #00FFFF'
print*
print*, 'yellow is rgb(255,255,0) which is HEX #FFFF00'
print*

! For a line in the %pl region which is cyan (for example) replace your equivalent line:
write(str1,"(a,z6.6,a)")           "%pl[colour=#", RGB@(0,255,255), "]"

!with this:
write(str2,"(a,3z2.2,a)")          "%pl[colour=#", 0,255,255,       "]"

print*, 'str1:  ', str1
print*, 'str2:  ', str2

end
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: Wed Oct 20, 2021 11:31 pm    Post subject: Reply with quote

Yes! This was the solution.
Ken, i owe you! This devilry tricked me so much that even comparing colors i have not noticed differences but they existed
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Tue Oct 26, 2021 8:48 am    Post subject: Reply with quote

Paul,
In your first answer to my post you have shown how to use set_plot_mode@(1) and there you have plotted an example of draw_filled_polygonD@.

Question: are polygons' borders antialiased like they are for the lines ? Here is cut from my other program which uses this method and it plots gray vertical polygons stacked one near another from left to right with gradually changing color. And also shown is the line. Clearly the line is antialiased for smoothness which is good. But what happens with the polygons is that they sometimes mess the plot by leaving antialased lines of lighter colors. The whole gray gradient has to be very smooth but it is now not. Is it possible to switch off antialiasing specifically for polygons and switch it on again for everything else?


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



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

PostPosted: Tue Oct 26, 2021 8:49 pm    Post subject: Reply with quote

Somehow i do not see antialiasing on you own example. Only numbers are antialiased


Look below what the perfection can %PL create in minutes. And i did not yet used Designer mode to improve it. Why crazy fortraneers do not use Clearwin like crazy is beyond my comprehension.
The only problem left is spurious antialiasing of these gradients
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Oct 27, 2021 8:49 am    Post subject: Reply with quote

In my sample program the smoothing mode is set to 5 in the main program and this value is used when calling draw_curvesD@.

At the moment you can't dynamically change the %pl smoothing mode by a call to set_smoothing_mode@ but I have made the necessary changes so that this call will work in the future.

draw_curvesD@ will provide smoothing even when you don't ask for it (mode = 0) so if you want no smoothing then you must call set_smoothing_mode@(3) which is also a no-smoothing mode.

In the following sample (which will work with the next release of ClearWin+) the default %pl smoothing mode is 5 but the curve is draw without smoothing.
Code:
      WINAPP
      MODULE mymod
      USE clrwin
      INTEGER,PARAMETER::N=11
      DOUBLE PRECISION x(N),y(N)
      CONTAINS
      INTEGER FUNCTION cb()
      CALL set_plot_mode@(1)
      CALL set_line_width@(4)
      is = set_smoothing_mode@(3)
      CALL draw_curvesD@(x,y,N,RGB@(0,0,255))     
      is = set_smoothing_mode@(is)
      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*(i-6)
        y(i)=x(i)*x(i)
      ENDDO
      i=winio@('%ca[Quadratic]%pv&')
      CALL winop@("%pl[title=Graph]")
      CALL winop@("%pl[y_max=0.25]")
      CALL winop@("%pl[x_array]")   
      CALL winop@("%pl[smoothing=5]")
      CALL winop@("%pl[link=user]")
      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
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Wed Oct 27, 2021 9:26 am    Post subject: Reply with quote

Great, thanks Paul.
One more small suggestion for potential improvement: when i exit the plot made with this new option set_plot_mode@(1) what happens is that, say, draw_line_betweenD@ is still performing plotting in this mode but plot is already destroyed before set_plot_mode@(0) is called at the end of its subroutine and i get crash with "Error: The current drawing surface is not from %PL graph"

Things are that cancelling plots usually happens very many times per day without waiting when it finishes plotting (plotting may be performed by the running code automatically every second or so to catch specific moment).

Crashing in this case is crashing the entire code, not just this specific plot, and this is very painful experience. Would be great if such error message appeared without crash, it's OK to have such message but preferably that it disappear when you just touch it with the mouse (adding to message the %sv). I think conflict appears because there are many other %GR and %PL windows in regular mode (set_plot_mode@(0) ) still open when you cancel set_plot_mode@(1) plot


Last edited by DanRRight on Wed Oct 27, 2021 10:17 am; edited 1 time in total
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Wed Oct 27, 2021 9:47 am    Post subject: Reply with quote

Dan

This particular error message already provides a message box with the option to continue without raising an exception.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Wed Oct 27, 2021 10:15 am    Post subject: Reply with quote

Cool, thanks
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Fri Dec 17, 2021 8:13 am    Post subject: Reply with quote

I had the following problem with new mode the example of which was shown by Paul as the first demo code in this thread. Somehow the draw_line_betweenD@ misses %PL window and when CWP detests that it allows to avoid the crash by offering an option (popped some window) to ignore the problem but when i click Ignore All, the code still stops in Debugger as an Error and i have to restart the program.



I suspect this may happen because i use %lw at the end of the function which is opening %PL window (see the last picture above. I use %lw to allow other windows to be available during the run) so that when draw_line_betweenD@ starts numerous plots inside large DO loop, it sees other graphics windows as active ones in normal standard mode not in set_plot_mode (1). And when protection to avoid the crash kicks in to resolve the problem, it still somehow does not succeed

This is already part of large code and i can not extract the demo. May be this info is enough to suggest the solution to avoid this crash. Or may be some more strong protection could be possible to add to CWP so that draw_line_betweenD@ will ignore and do not crash when missing needed mode or even will not crash when there is no any graphics windows at all
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Fri Dec 17, 2021 8:40 am    Post subject: Reply with quote

Dan

I would start by using clearwin_string@("CALLBACK_REASON") within the drawing function (if you are not doing so already). Find the "reason" corresponding the required drawing and make this a condition...

IF(clearwin_string@("CALLBACK_REASON") == "....")THEN....
Back to top
View user's profile Send private message AIM Address
DaveyG



Joined: 29 Oct 2021
Posts: 2

PostPosted: Thu Jun 23, 2022 5:59 pm    Post subject: Reply with quote

hello, - i was just wondering around looking at posts and was attracted by the colourfulness of the last plot posted on page 1 - nice DanRight
just one question - on the vertical scale, how can the exponent be raised up like on the first plot again on p.1 at the beggining - also i may have bad eyes but are those numbers centred on the marks on the axis or slightly shifted? - what's the procedure for positioning the values in a particular location relative to the ticks?
Back to top
View user's profile Send private message
DaveyG



Joined: 29 Oct 2021
Posts: 2

PostPosted: Thu Jun 23, 2022 6:08 pm    Post subject: Reply with quote

ah-sorry, just spotted something else on the second graph- how is the variable number of decimal points specified for the alternate numbers again on the vertical axis ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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