View previous topic :: View next topic |
Author |
Message |
Kenneth_Smith
Joined: 18 May 2012 Posts: 840 Location: Lanarkshire, Scotland.
|
Posted: Wed Aug 13, 2025 12:10 pm Post subject: %pl[frame,scale=linear_log] |
|
|
Paul,
Something that needs looking at when you have time. In the second %pl graph the options frame and scale=linear_log are used. The resulting plot is not correct. Please see my mark up here:
https://www.dropbox.com/scl/fi/whuaiw6wfwhy8zpu0r6ss/Screenshot-2025-08-13-120045.jpg?rlkey=pqjut46zi1uabeqk6netkmbtk&st=rl1kaxh5&dl=0
Code: |
program p
use clrwin
implicit none
integer, parameter :: n = 100
integer :: i, iw
real*8 :: x(n), y(n)
real*8 :: xend = 10.d0**3, xstart = 10.d0**(-1), twopi = 8.d0*atan(1.d0)
! Log spaced x values
x = [( 10.0d0**(log10(xstart) + (i-1)*(log10(xend)-log10(xstart))/(n-1)), i=1,n )]
! y(x) = sin(2pi * log10(x)) will produce a repeating sine pattern evenly
! spaced on the semilog x-axis so you can immediately tell if the x-axis
! is scaled correctly.
y = sin(twopi*log10(x))
iw = winio@('%fn[Tahoma]%bf%ts&',1.5d0)
call winop@('%pl[n_graphs=1,native,width=3,gridlines]')
call winop@('%pl[colour=red,x_array,scale=linear_log]')
iw = winio@('%ta%pl&', 600, 600, size(y,kind=3), x, y)
call winop@('%pl[n_graphs=1,native,width=3,gridlines]')
call winop@('%pl[frame]')
call winop@('%pl[colour=red,x_array,scale=linear_log]')
iw = winio@('%ta%pl', 600, 600, size(y,kind=3), x, y)
end program p |
|
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Wed Aug 13, 2025 2:02 pm Post subject: |
|
|
Thanks. I will take a look at this. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Thu Aug 21, 2025 3:17 pm Post subject: |
|
|
Ken
All the tick values ought to be at the bottom when using [frame] and I have fixed this. The alternative [framed] works correctly in this context. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Thu Aug 21, 2025 3:59 pm Post subject: |
|
|
Ken
I added
call winop@('%pl[y_min=-1.005]')
to both for the graphs in your code in order to display the lowest y value and grid line. |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 840 Location: Lanarkshire, Scotland.
|
Posted: Mon Aug 25, 2025 11:07 pm Post subject: |
|
|
Paul, Thanks for the recent DLLs with updates.
Your suggestion of call winop@('%pl[y_min=-1.005]') got me thinking. The �obvious� value for y_min is -1, and where does the additional 0.005 come from?
Suppose the y data ranges from ymin to ymax, then the corresponding �nice� range for the y axis might be yminp to ymaxp spanning y_range = ymaxp - yminp
The range of the y_axis in pixels is gh � top � bottom, where gh is graphics depth and top and bottom are margins. All of these are known or can be calculated. Call the resulting integer value y_range_pix.
So we can calculate y_per_pix = y_range/y_range_pix. Where the correction is required to show the minimum y value the additional value (subtracted from the obvious ymin value) is y_per_pix.
This correction can be calculated dynamically at runtime, allowing the graphic to be stretched vertically via a pivot, or if the data changes.
The code below explores this idea, although probably needs more work!
https://www.dropbox.com/scl/fi/9chqvm9bigraz35kja5fv/set_ymin_auto.f95?rlkey=ssybl8p69wjt5aqhzlea0j7ap&st=i4hjkmi9&dl=0
Last edited by Kenneth_Smith on Tue Aug 26, 2025 8:05 am; edited 1 time in total |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Tue Aug 26, 2025 7:09 am Post subject: |
|
|
Ken
The additional value was just a guess at something to make it work.
%pl could probably be improved in this respect but I don't know how much time it would take.
Changes of this nature must of necessity be minimal in order to avoid breaking existing usage. |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 840 Location: Lanarkshire, Scotland.
|
Posted: Tue Aug 26, 2025 9:43 am Post subject: |
|
|
Paul,
I too have been guessing the value when I�ve encountered the problem in cases where the limits are well defined.
The relationship:
Code: |
Yminpl = Ymin_desired - (Ymax_desired - Ymin_desired)/(graphics_height � top_margin � bottom_margin) |
may be useful to others encountering this problem and eliminate guessing - particularly as the y data range and also the size of %pl region and its margins change.
The �correction� is only required if ymin_desired .LE. 0.0 and ymax_desired .GE. 0.0 are both true.
I got rather carried away testing different values and adding pivots to test this yesterday! The program I posted obscures the simplicity of the underlying calculation. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Tue Aug 26, 2025 10:27 am Post subject: |
|
|
Thanks Ken. That is helpful. I will see what I can do. |
|
Back to top |
|
 |
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8257 Location: Salford, UK
|
Posted: Wed Sep 10, 2025 11:46 am Post subject: |
|
|
Ken
I have made some adjustments in order to include your formula. |
|
Back to top |
|
 |
Kenneth_Smith
Joined: 18 May 2012 Posts: 840 Location: Lanarkshire, Scotland.
|
Posted: Thu Sep 11, 2025 10:28 am Post subject: |
|
|
Thanks Paul, That should eliminate some guesswork! |
|
Back to top |
|
 |
|