Silverfrost Forums

Welcome to our forums

Suggestion - native %pl

17 Aug 2020 11:39 #26242

In addition to the present options in the native %pl for link (i.e. none, lines, curves) a useful future addition would be “spectrum”.

This would treat the x,y data input to %pl as frequency and magnitude data, and for each data point i it would draw a single line between two points i.e. ( x(i), y(i) ) and ( x(i), 0 ), creating a spectrum type plot.

I know this can be achieved indirectly by using the %pl call back or by careful stacking of the input data into multiple graphs, but I suspect that a more direct method would be useful to “new” users trying to plot such frequency domain plots before they conclude that %pl cannot use used to display data in this format.

Ken

17 Aug 2020 1:46 #26243

Ken

Thanks for the suggestion.

18 Aug 2020 6:31 #26245

Maybe two weeks say.

Would it only be vertical lines? If also horizontal lines (x(i),y(i)) to (0,y(i)), what would you call that?

19 Aug 2020 12:36 #26246

Paul,

I don’t see a need for horizontal lines, but I suppose somebody out there might have such a requirement. “Column” or “stem” instead of “spectrum” and “bars” and for the horizontal lines, or perhaps “y_spoke” and “h_spoke”, or “y_stem” and “h_stem” if you prefer a mechanical or botanical analogy?

For my applications, on occasion, both the x (frequency) and y (magnitude) data can become negative, so it’s not just the first quadrant I am thinking about.

Thanks

Ken

26 Aug 2020 11:26 #26267

The 'link' option for %pl has been extended to provide [link=columns] and [link=bars]. The first gives columns from the x-axis to the data points. The second gives bars from the y-axis to the data points. The width of a column and the height of a bar is determined by the selected line width.

26 Aug 2020 11:48 #26269

Paul,

Thanks for this addition.

Ken

27 Aug 2020 2:39 #26281

John,

Here is the code for a simple test I've just run. You must explicitly specify a value for width.

!Spectrum test
use clrwin
implicit none
integer, parameter :: dp = kind(1.d0)
integer, parameter :: n = 10
real(kind=dp):: mag(1:n) = 0.d0, h(1:n)=0.d0
integer i, iw

do i = 1, n
  mag(i) = 1.d0/i
  h(i)   = i
end do

iw = winio@('%mn[Exit]&','exit')
iw = winio@('%fn[Tahoma]%ts&',1.5d0)
call winop@('%pl[native,independent,x_array,gridlines,frame,link=columns,width=10,colour=blue]')
call winop@('%pl[Title='Harmonic content of a square wave']')
call winop@('%pl[x_axis='Harmonic order',y_axis='Harmonic magnitude',dx=1,x_max=10.5,y_min=0,dy=0.25,y_max=1]')
iw = winio@('%pl&',600,400,n,h,mag)
iw = winio@(' ')
end 

Here is a link to the image:

https://www.dropbox.com/s/81txtrnjghfg7zy/spectrum.jpg?dl=0

PS I have just sent myself to the bottom of the class! There should be no even harmonics in a symmetrical waveform!

10 Oct 2020 4:26 #26459

I have looked at this and for this sample on my machine the position needs to be 1 or 2 pixels to the level. I opted for 1 pixel and ran my %pl test suite.

Everything was OK except for one similar (single digit) case where the position became off centre the other way.

I have retained the shift left by one pixel so this sample will look better but the change could have an adverse effect in some cases.

Please consider this matter as closed.

Please login to reply.