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 

Simpleplot ticks
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Suggestions
View previous topic :: View next topic  
Author Message
DanRRight



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

PostPosted: Mon Feb 25, 2013 12:40 am    Post subject: Simpleplot ticks Reply with quote

Guess where are corresponding to numbers ticks in this Simpleplot graph? They are marked in red! This is decades old problem, any chance to fix the tic vs axis numbers position?



Uploaded with ImageShack.us
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Mon Feb 25, 2013 7:41 am    Post subject: Reply with quote

Sorry but SIMPLEPLOT is a third party DLL and we do not have access to the code.
Back to top
View user's profile Send private message AIM Address
DanRRight



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

PostPosted: Mon Feb 25, 2013 10:37 pm    Post subject: Reply with quote

The guy is off business, can you ask him to leave you sources? It is a big hole when the part of Clearwin will be completely dead. Or may be good to consider new more advanced 3D/Opengl graphics package. I've heard opinion that some professors, for example, chose Matlab for students only for its excellent professional looking graphics easy done in one line. Aging Simpleplot or Simdem need face lift in this department. Clearwin needs great graphics which can be done in single Fortran line of text so that everyone's reaction will be "I want it!".
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


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

PostPosted: Tue Feb 26, 2013 8:58 am    Post subject: Reply with quote

Hopefully we can duplicate the ClearWin+ usage of SIMPLEPLOT before too long.
Back to top
View user's profile Send private message AIM Address
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Wed Jun 11, 2014 3:32 pm    Post subject: A (Partial) Tick Marks Problem Solution Reply with quote

Having done a bit of homework on SimplePlot, it's perceived shortcomings, I have uncovered at least a partial solution.
(I take no credit here as I came across the 'hint' in one of Agustin (aebolzan)'s posts from 5 years ago !)
Dan has kindly sent me the source code

Below is the original code , together with 2 additional SimplePlot commands which improve the appearance of the Tick Labels.

WINAPP
Real*8 x(100), y(100)
N=100
do i=1,N;
x(i)=i-1;
y(i)=sin(i/30.)**2;
enddo
C
C - 2 additional direct calls to SimplePlot functions
C to set parameters to modifiy axes labels appearance
C
C - modify MINIMUM nominal character width (applies to all text)
CALL TEXTMN(0.3)
C - modify labels positions
CALL AXLBJS('*C','C')
C
i=winio@('%pl[x_array]', 300, 200, N-4, x, y)
End




Here below is the output of the Original code and 3 variations, one just adding the cal lto AXLBJS on it's own (resolving the X-axis positioning perfectly, but the Y-axis is still not perfectly geometrically centred.
2 other runs with 2 different values of TEXTMN (minimum text size in cm) of 3mm then 2mm then show how further modifications can be made. Note that SimplePlot has a lot of 'automation' of title and label text sizes built into it, which explains why on the smallest 2mm text size labels suddenly appear at each tick mark. Other parameters may help 'force' the labelling at every other tick mark if that's what's required.

NOT a perfect solution of course, but it helps for those who don't have the time (or inclination) to delve too deeply into the SimplPlot commands method of plotting.
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Wed Jun 11, 2014 3:39 pm    Post subject: Reply with quote

Sorry, the code above had the first 6 columns mysteriously disappear when I posted it !
Either add the 6 spaces in front of each (non-comment) line and run as F77 code or change to 'C' on the comment cards to the correct '!' symbol to be F95 compatible, either should then run, although I've only run the F77 version.
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Thu Jun 12, 2014 9:07 am    Post subject: Reply with quote

John,
That was great trick.
And if...if you also find similar simple workaround on how to
1) change line thickness
2) make the square frame (upper and lower x axis and left and right y axis)
3) change the font for axis ticks and labels

then Simpleplot %pl will really get out of grave
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2388
Location: Yateley, Hants, UK

PostPosted: Thu Jun 12, 2014 1:16 pm    Post subject: Reply with quote

Hi John,

If you want the Fortran code you post to appear as you wrote it, then highlight it and click the Code button above (same as doing bold or underline etc.) This puts the tags at the beginning and at the end, so the forum interprets it correctly, like this:.

Code:
C     Fortran in here

Eddie
Back to top
View user's profile Send private message
aebolzan



Joined: 06 Jul 2007
Posts: 229
Location: La Plata, Argentina

PostPosted: Thu Jun 12, 2014 5:26 pm    Post subject: Reply with quote

You can change the line thickness by including these lines in the program:

call thckmg('LINE',2.0) !or any reasonable real*4 number

you can change 'LINE' with either T for text, M for markers or * for all these

and for the the font type

call chset(-12) !or any number between -1 and -12, as I showed in the Clearwin forum

the problem with the axis is likely a problem of %pl, as it admits only a single x and y pair.....I do not know how %pl was implemented, so that I do not know if it would be at all possible to draw four axis with %pl....this is a question for Paul.....if you don't use %pl, I think it would be possible to draw the four axis by means of the AXIS7 and AXLOCN subroutines, but I never tried....

Agustin
Back to top
View user's profile Send private message
aebolzan



Joined: 06 Jul 2007
Posts: 229
Location: La Plata, Argentina

PostPosted: Thu Jun 12, 2014 7:49 pm    Post subject: Re: Reply with quote

DanRRight wrote:
John,
That was great trick.
And if...if you also find similar simple workaround on how to
1) change line thickness
2) make the square frame (upper and lower x axis and left and right y axis)
3) change the font for axis ticks and labels

then Simpleplot %pl will really get out of grave


Seemingly you cannot do that with %pl but you can use Simpleplot as follow:

Code:
program Simpleplot_plots
!requires simpleplot.dll and spwin module
use mswin
use spwin
implicit none
real*4,dimension(70) ::xarr,yarr
integer*4 :: narr,ltype,xscale,yscale
integer*4 :: ctype,i,ans
character(8) :: xlabel="x",ylabel="y"
character(2) :: istr
real*4 :: minx,maxx,miny,maxy,ins

narr=0
do i=1,70
  xarr(i)=2*i
  yarr(i)=i*i
  narr=narr+1
end do
HDC_DIM%iWidth = 800
HDC_DIM%iHeight = 800
HDC_DIM%iBitmapDC = GET_Bitmap_DC@(HDC_DIM%iWidth, HDC_DIM%iHeight)
CALL SP_SupplyBitmap     ! Pass Bitmap to SIMPLEPLOT
call picpos(4.0,5.0) ! locate the graph in the page so that everything enters
call textmg(1.5)     !size of the text
call axsbtk('XC','I') !ticks inside for x axis
call axsbtk('YC','O') ! ticks outside for y axis
CALL AXLBJS('**', 'Centre') ! labels centred
minx=minval(xarr)
maxx=maxval(xarr)
miny=minval(yarr)
maxy=maxval(yarr)
xscale=1;yscale=1
CALL SCALES(minx,maxx,xscale,miny,maxy,yscale) ! draw scales for main plot
call axcrss('YC',minx)! x-y crossing at xmin
ltype=-1 !line type
ctype=1 !curve type
call chset(-8) ! character set
call cvtype(ctype) ! curve type
call thckmg('LINE',3.0) !thickness of lines
call pen(4) !pen colour
CALL AXES7(xlabel, ylabel) !draw axes with labels
CALL AXLOCN('YCartesian', 'Following') ! locate a new y axis on right
call  axlban('yc','O') ! tick labels towards the outside
call axsbtk('yc','O') !ticks outside for y axis on the right
!call axclr('yc',1)! only axis is drawn if you prefer
call axis7('YC',' ') ! draw the new y axis without title                     
CALL AXLOCN('XCartesian', 'Following') !locate a new x axis on top
call  axlban('xc','N') ! no tick labels                 
call axsbtk('xc','I') ! ticks inside
call axis7('XC','   ') ! no axis label                                                                                             
call thckmg('L',1.0) !line thickness = 1
call pen(2)!  colour red
CALL BRKNCV(real(xarr,1),real(yarr,1),narr,ltype)! draw curve
ans=winio@('%ca[A Simple Plot with Simpleplot]%bg[grey]&')
ans=winio@('%dw&',HDC_DIM%iBitmapDC) ! Pass bitmapDC to ClearWin
ans=winio@('%ff%nl%cn%6bt[Close]')
end program simpleplot_plots


Agustin
Back to top
View user's profile Send private message
aebolzan



Joined: 06 Jul 2007
Posts: 229
Location: La Plata, Argentina

PostPosted: Thu Jun 12, 2014 7:52 pm    Post subject: Reply with quote

....and in case you don't have the spwin module:

Code:
MODULE SPWIN ! Contains definition of values to pass to DDDATA
INTEGER,PARAMETER :: SIMPLE_WINDOWS_WINDOW=1,SIMPLE_WINDOWS_PRINTER=2, &
&SIMPLE_WINDOWS_DIB=4,SIMPLE_WINDOWS_METAFILE=8,SIMPLE_PERCENT=0,SIMPLE_PIXELS=1,SIMPLE_MM=2
TYPE SIMPLE_WINDOWS_DATA_STRUCT_T
INTEGER :: iOpc ! Corresponds to C++ long int
INTEGER :: iPtr ! Address of OpCode specific data
END TYPE SIMPLE_WINDOWS_DATA_STRUCT_T
TYPE SIMPLE_WINDOWS_HDC_DATA_T
INTEGER :: hDC ! device context handle
INTEGER :: iWidth, iHeight ! plotting area
END TYPE SIMPLE_WINDOWS_HDC_DATA_T
TYPE SIMPLE_WINDOWS_SIZE_T
INTEGER :: iUnits ! SIMPLE_PERCENT, ..._PIXELS, ..._MM
INTEGER :: iWidth, iHeight, iDepth
END TYPE SIMPLE_WINDOWS_SIZE_T
TYPE SIMPLE_WINDOWS_ORIGIN_T
INTEGER :: iUnits ! SIMPLE_PERCENT, ..._PIXELS, ..._MM
INTEGER :: iX, iY
END TYPE SIMPLE_WINDOWS_ORIGIN_T
TYPE HDC_DIM_TYPE
INTEGER*4 iBitmapDC, iWidth, iHeight
END TYPE HDC_DIM_TYPE
TYPE (HDC_DIM_TYPE) :: HDC_DIM
INTEGER, PARAMETER :: SIMPLE_WINDOWS_END_LIST = 0
INTEGER, PARAMETER :: SIMPLE_WINDOWS_SET_WINDOWNAME = 6
INTEGER, PARAMETER :: SIMPLE_WINDOWS_SET_HDC_DIM = 7

! Useful definition of data structure to hold BitmapDC to pass to SIMPLEPLOT

Contains

SUBROUTINE SP_SupplyBitmap ! Pass Bitmap to SIMPLEPLOT
! Set up a Static (SAVEd) array of OpCodes. Each OpCode consists of an
! OpCode ID followed by an optional address of a data structure.
! The parameter block address is passed to SIMPLEPLOT by SUBROUTINE DDDATA.
!
! In this example:
! SIMPLE_WINDOWS_SET_HDC_DIM specifies that the next integer is the address
! of a data structure consisting of a Bitmap DC followed by its dimensions
! SIMPLE_WINDOWS_END_LIST is the mandatory end of list item which does not
! require the address of a structure
TYPE(SIMPLE_WINDOWS_DATA_STRUCT_T), DIMENSION(2) :: OpCodes
SAVE OpCodes
OpCodes(1)%iOpc = SIMPLE_WINDOWS_SET_HDC_DIM ! hDC + dimensions
OpCodes(1)%iPtr = LOC(HDC_DIM) ! See definition of SPWIN above
OpCodes(2)%iOpc = SIMPLE_WINDOWS_END_LIST! End of list
CALL DDDATA(LOC(OpCodes))! Notify SIMPLEPLOT
CALL DEVNAM('WINDOW') ! Select Window
CALL OWNNEW(.TRUE.) ! Inhibit 'Continue' button
END subroutine SP_SupplyBitmap

!this subroutine is needed if the content of the graph window changes during the program run
SUBROUTINE UpdateWin
CALL OUTBUF ! Flush buffers
CALL WINDOW_UPDATE@(HDC_DIM%iBitmapDC) ! Copy Bitmap to window
END subroutine UpdateWin
END MODULE SPWIN


Hope this helps,

Agustin
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Thu Jun 12, 2014 11:24 pm    Post subject: Reply with quote

SPWIN, is this one of your routines ?
I seem to remember seeing it somewhere else, maybe in documentation or on forum posts somewhere. Is it a 'standard' routine ?
(maybe I'm getting mixed up with MSWIN below.)

Also the program calls MSWIN, what's that . Is it included i nthe FTN95 install maybe ?
Back to top
View user's profile Send private message
aebolzan



Joined: 06 Jul 2007
Posts: 229
Location: La Plata, Argentina

PostPosted: Thu Jun 12, 2014 11:48 pm    Post subject: Reply with quote

The module SPWIN defines a series of variables needed for using Simpleplot with Clearwin. In this way you can use all the Simpleplot routines inside a %dw window. This is not my creature: it was included in the old manuals of Simpleplot when people from Salford and Bradford universities were working closely, i.e. FTN90/95 and Simpleplot developers. Therefore, you need it if you prefer to use the full power of Simpleplot instead of the simpler implementation with %pl.

In the old times it was common to use WINAPP as the first statement in the FTN90/95 programs, but later it was replaced by "use mswin" where the MSWIN is a module provided by FTN95 for developing programs for runing as Windows applications.

Hope this helps,

Agustin

P.S. by the way, I wrote here the SPWIN module again because I guessed some reader in this forum perhaps did not read some old posts in the Clearwin forum where I posted it when discussing some other example referred to Simpleplot. Paul said something about including it in a following update of the compiler...but I do not know if he did it....
Back to top
View user's profile Send private message
DanRRight



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

PostPosted: Fri Jun 13, 2014 2:39 am    Post subject: Reply with quote

Thanks Agustin for the tricks. Will explore them in detail.

With Simpleplot I hope we all learned one major lesson I got even before that and tried to follow: nothing in your code has to be third party you have no full control of. From the start Salford compilers allowed to implement that principle. The only single step aside was Simpleplot %pl and now we pay for that. Even if %pl is just a tiny part of FTN95 its deficiencies are painful when you can not fix or improve anything. The idea behind %pl is great though. Same one is used in Matlab where it also has great professional implementation making plotting ultimately simple and immediately ready for any scientific journals. We discussed that before few times.
http://forums.silverfrost.com/viewtopic.php?t=2724

Hopefully developers will do something here some day

By the way does the whole Simpleplot package use real*4 only? Not that i plan to use not supported anymore third-party package with no source code, just curious
Back to top
View user's profile Send private message
aebolzan



Joined: 06 Jul 2007
Posts: 229
Location: La Plata, Argentina

PostPosted: Fri Jun 13, 2014 4:09 pm    Post subject: Reply with quote

Hello Dan,

I have just wrote in another topic that the problem with ticks are seemingly solved (I have to test this more deeply, but at first glance seems it works) with the use of the software fonts of Simpleplot.

Respect to the variables, yes, Simpleplot uses Real*4, no double precision at all. Why? I do not know, but people from BUSS never "upgraded" the variables from single to double precision. I know not too much about programming, but maybe they considered that for a graph, single precision was enough, and required less memory and computer time. The problem of using a third party implementation has the problem that it works as far as the developers are active, but in this case, I think, it would be the same with FTN95: if you implement a lot of code using subroutines from the FTN95 libray and Silverfrost disappears one day, you could have a similar problem....at least for Simpleplot, thanks God that David Butland left the library and documentation in the hands of Salford/Silverfrost.....

The idea of implementing %pl is great.....if you want a fast simple way to plot a "simple" plot, but when you have such amount of options, i.e. subroutines, for designing the plot, I guess it would be quite difficult to implent all that under %pl, because you will need to write a long,long statement.....%pl is great for testing a program, but once you have all the program running fine, I think it is better to include Simpleplot routines one by one and control the graph more carefully....

just my thoughts,

Agustin

From the document Using SimplePlot with FTN95 (http://www.silverfrost.com/23/ftn95/support/documentation.aspx) :

4.1 Arguments to Simpleplot
The Simpleplot library is compiled using 4 byte integers and 4 byte reals. If you use different sized variables, you must be sure that variables passed to Simpleplot are correctly specified.
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 -> Suggestions All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
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