SharpPlot, tables within the graphic

General APL language issues

SharpPlot, tables within the graphic

Postby Leo on Mon Jan 15, 2018 1:23 pm

Version: 16.0.31693.0 64 Unicode
Created: Dec 3 2017 at 19:58:11
Windows 7

Subject: SharpPlot, tables within the graphic

Hello DyalogAPL'er

I have some basic questions for me about creating 2D charts with SharpPlot.
The example shown "DProfil" is executable, but should still be supplemented.
What I have not been able to figure out yet is how to create tables and insert them into the 2D diagram.

1st question: How to create a table for the "profile coordinates"?
The values X, Y1 and Y2 should be written in a 3-column table with the respective headings X, Y1 and Y2 and finally put anywhere in the diagram.
2nd question: How to create a table for the "profile parameters". In the first column should be the names, in the second column the corresponding values

For the tables, which can be arranged anywhere in the diagram, I kept the place in the code list.
      DProfil;dat;sp;⎕USING;XY;X;Y1;Y2;XY1Y2
⍝ D:\DyalogAPL\ws3\SPTutorial.dws --- DProfil
⍝ Profilkoordinaten:
X←0 0.01 0.02 0.05 0.1 0.25 0.5 0.6 0.7 0.8 0.9 1
Y1←0 0.0307 0.0411 0.0579 0.0699 0.074 0.0552 0.0456 0.0367 0.0292 0.0229 0.0176
Y2←0 ¯0.0307 ¯0.0411 ¯0.0579 ¯0.0699 ¯0.074 ¯0.0552 ¯0.0456 ¯0.0367 ¯0.0292 ¯0.0229 ¯0.0176
⍝ Profilparameter:
XDMAX←0.19 ⍝ Testeingabe
DMAX←0.15 ⍝ Testeingabe
RN←0.4 ⍝ Testeingabe
RH←0.11737 ⍝ Testeingabe
WA←6 ⍝ Testeingabe
⍝ ⍝ = INIT ===============================================================================
⎕USING←',sharpplot.dll' ',system.drawing.dll' ⍝ ⎕USING: Aufruf der .NET-Suchpfade für sp-Namespaces
⎕USING,←('Causeway,sharpplot.dll')('CausewayViewer,sharpplot.dll')
⎕USING,←'System.Windows.Forms,System.Windows.Forms.dll' 'System.Drawing,System.Drawing.dll' ''
⍝ ======================================================================================
⍝ PaperSize:
⍝ sp←⎕NEW Causeway.SharpPlot
sp←⎕NEW SharpPlot(PaperSize.Landscape⊂PaperSize.A7) ⍝ DIN A4-Format 298x211 mm
⍝ Heading: ------------------------------------------------------------------------------
sp.Heading←'D-Profil'
sp.SetHeadingFont'Arial' 12 System.Drawing.FontStyle.Regular System.Drawing.Color.Green
sp.SetHeadingNudge(0,-280) ⍝ Position der Überschrift (horizontal,vertikal)
⍝ Subheading: ---------------------------------------------------------------------------
sp.Subheading←'Grundprofil'
⍝ Footnote: -----------------------------------------------------------------------------
sp.Footnote←'D:\DyalogAPL\ws3\SPTutorial.dws --- DProfil'
sp.SetFootnoteFont'Arial' 4 System.Drawing.FontStyle.Regular System.Drawing.Color.Black
sp.FootnoteStyle←Causeway.FootnoteStyles.Right
⍝ Data Table 1: Profilkoordinaten -------------------------------------------------------





⍝ Data Table 2: Profilparameter ---------------------------------------------------------





⍝ GridLines: ----------------------------------------------------------------------------
sp.LineGraphStyle←Causeway.LineGraphStyles.GridLines
⍝ Margins (Ränder) ----------------------------------------------------------------------
sp.SetMargins 30 40 50 60 ⍝ top - bottom - left - right
⍝ Axis: ---------------------------------------------------------------------------------
sp.XAxisStyles←Causeway.XAxisStyles.CenteredCaption
sp.SetAxisStyle(Color.Black,LineStyle.Solid,0.8)
sp.XCaption←'X[-]' ⍝ Beschriftung der X-Achse
sp.YCaption←'Y[-]' ⍝ Beschriftung der Y-Achse
sp.XIntercept←0 ⍝ Schnittpunkt der Y-Achse mit der X-Achse
sp.YIntercept←¯0.3 ⍝ Schnittpunkt der X-Achse mit der Y-Achse
sp.SetXRange(0 1) ⍝ Scala der X-Achse
sp.SetYRange(¯0.3 0.3) ⍝ Scala der Y-Achse
⍝ Draw: ---------------------------------------------------------------------------------
sp.SetColors⊂System.Drawing.Color.Navy
sp.SetLineStyles⊂Causeway.LineStyle.(Solid)
sp.SetPenWidths⊂0.6 ⍝ Liniendicke Profil
sp.DrawLineGraph Y1 X ⍝ zeichnet Y1 vs. X
sp.DrawLineGraph Y2 X ⍝ zeichnet Y1 vs. X
⍝ = Output =============================================================================
⍝ - Graphic in *.png - write file ------------------------------------------------------
sp.SaveImage'D:\DyalogAPL\ws3\DProfil.png'System.Drawing.Imaging.ImageFormat.Png
⍝ - Graphic in *.pdf - write file ------------------------------------------------------
sp.SavePdf⊂'D:\DyalogAPL\ws3\DProfil.pdf'
⍝ - Graphic on screen show -------------------------------------------------------------
viewer←⎕NEW SharpPlotViewer
viewer.SharpPlot←sp
viewer.Show ⍬
⍝ ======================================================================================

3rd question: The pdf diagram appears very small in the lower left corner. How do you get the diagram to fill the entire paper surface (A7)?

4th question: On the X-axis the zero (0) is omitted. How can I get the 0 to appear?


Many thanks in advance for your help!

Leo
Leo
 
Posts: 14
Joined: Mon Sep 18, 2017 12:10 pm

Re: SharpPlot, tables within the graphic

Postby Nicolas|Dyalog on Mon Feb 05, 2018 12:32 pm

Q1: after you've drawn the last linegraph, you can add a table with something like
Code: Select all
 sp.TableStyle←Causeway.TableStyles.(Boxed+GridLines+Opaque)
 sp.SetTablePosition 0.1 0.3  ⍝ in previous chart coordinates   
 sp.DrawTable⊂X Y1 Y2

You might have to decrease the ValueFont so that it takes less space
Have a look at http://sharpplot.com/Tabulations.htm for more examples

Q2: same answer as Q1.

Q3: That sounds like a bug in SharpPlot, but I can't reproduce it with the latest version. Download it from http://my.dyalog.com and your problem should be gone

Q4: That's a bug and I can reproduce it with the latest version. Will be fixed in v3.54. In the meantime, commenting out the line that sets XIntercept to 0 works around it.

Cheers,

Nic.
Nicolas|Dyalog
 
Posts: 8
Joined: Wed Sep 10, 2008 9:39 am

Re: SharpPlot, tables within the graphic

Postby Leo on Mon Feb 12, 2018 3:17 pm

Hello Nic,
Thank you for your answer and the hints, which helped me with my table problem. A big help was also your video (https://video.dyalog.com/Dyalog14/?v=it1MzL9DqlY).

The following 2D plot version DProfil1 is an advancement of DProfil and should serve me "formulary". She is not perfect, but able to run!
I put them in the forum for people like me, Dyalog APL and SharpPlot beginners. My experiences with SharpPlot so far are very positive, if you have learned something.
      ∇ DProfil1;X;Y;ProfPara;Datum;XYY
[1] ⍝ Testbeispiel für SharpPlot 07.02.2018
[2]
[3] ProfPara←'XDMAX' 'DMAX' 'RN' 'RH' 'WA',[1.5]0.19 0.15 0.4 0.11737 6
[4] X←0 0.01 0.02 0.05 0.1 0.25 0.5 0.6 0.7 0.8 0.9 1
[5] X←X,⌽X
[6] Y←0 0.0307 0.0411 0.0579 0.0699 0.074 0.0552 0.0456 0.0367 0.0292 0.0229 0.0176
[7] Y←Y,⌽¯1×Y
[8] XYY←X[⍳13],Y[⍳13],[1.5]¯1×Y[⍳13]
[9]
[10] Datum←(2 0⍕⎕TS[3]),'.',(2 0⍕⎕TS[2]),'.',(4 0⍕⎕TS[1])
[11] ⍝'ProfPara' ⋄ ⍕ProfPara
[12] ⍝' X Y' ⋄ 10 4⍕X,[1.5]Y
[13]
[14] ⍝ ============================================================================================
[15] ⎕USING←'System.Drawing,system.drawing.dll' 'System.Drawing.Imaging' 'Causeway,sharpplot.dll'
[16] ⎕USING,←('Causeway,sharpplot.dll')('CausewayViewer,sharpplot.dll')
[17] ⎕USING,←'System.Windows.Forms,System.Windows.Forms.dll' 'System.Drawing,System.Drawing.dll' ''
[18] ⍝ ============================================================================================
[19]
[20] ⍝ PaperSize:
[21] sp←⎕NEW Causeway.SharpPlot
[22] sp←⎕NEW Causeway.SharpPlot(720 520)
[23] ⍝ sp←⎕NEW SharpPlot(PaperSize.Landscape⊂PaperSize.A7) ⍝ DIN A4-Format 298x211 mm
[24]
[25] ⍝ Äußerer Rahmen
[26] sp.SetFrameBackground System.Drawing.Color.Black Causeway.FillStyle.Solid 0.5
[27] sp.FrameStyle←Causeway.FrameStyles.Boxed
[28] sp.SetMargins 90 70 60 130 ⍝ top - bottom - left - righ (Randabstände)
[29] sp.Gutter←10 ⍝ Abstand Blattrand zu Rahmen
[30]
[31] ⍝ Chart1 (Line) ===============================================================================
[32] sp.Heading←'D-Profil'
[33] sp.SetHeadingNudge(0,-20) ⍝ Position der Überschrift (horizontal,vertikal)
[34] sp.SetHeadingFont'Times' 24 System.Drawing.FontStyle.Regular System.Drawing.Color.Black
[35]
[36] sp.Subheading←'Testbeispiel für SharpPlot' ⍝ Unter-Überschrift
[37] sp.SetSubheadingFont'Arial' 12 System.Drawing.FontStyle.Regular System.Drawing.Color.Black
[38]
[39] WSID←⎕WSID ⋄ WSID,'.DWS'
[40] sp.Footnote←WSID,'.dws DProfil1 ',Datum,' Ju ' ⍝ Fußnote: Dateipfad, FNS u. Datum
[41] sp.SetFootnoteFont'Arial' 8 System.Drawing.FontStyle.Regular System.Drawing.Color.Black
[42] sp.FootnoteStyle←Causeway.FootnoteStyles.Right ⍝ Fußnote am rechten Rand
[43]
[44] ⍝ Linienstil der Koordinatenachsen, Liniendicke 0.8:
[45] sp.SetAxisStyle System.Drawing.Color.Black Causeway.LineStyle.Solid 0.8
[46]
[47] ⍝ Beschreibung und Beschriftungsstil der Achsen:
[48] sp.SetCaptionFont('Arial')(13)(System.Drawing.FontStyle.Regular)(System.Drawing.Color.Red)
[49] sp.XCaption←'X[ - ]' ⍝ Überschrift der X-Achse
[50] sp.YCaption←'Y[ - ]' ⍝ Überschrift der X-Achse
[51] sp.XIntercept←0 ⍝ Schnittpunkt der X-Achse
[52] sp.YIntercept←¯0.2 ⍝ Schnittpunkt der Y-Achse
[53] sp.SetXRange(0)(1) ⍝ Scalenbereich der X-Achse (Xmin - Xmax)
[54] sp.SetYRange(¯0.2)(0.4) ⍝ Scalenbereich der Y-Achse (Ymin - Ymax)
[55] sp.XAxisStyle←Causeway.XAxisStyles.GridLines ⍝ X-Gitterlinien
[56] sp.YAxisStyle←Causeway.YAxisStyles.GridLines ⍝ Y-Gitterlinien
[57]
[58] ⍝ Schattierung innerhalb des Linienzuges:
[59] sp.SetFillStyles⊂Causeway.FillStyle.(Opacity18 Opacity78) ⍝ Innen - Rand
[60] sp.LineGraphStyle←Causeway.LineGraphStyles.SurfaceShading
[61] sp.DrawLineGraph(,⊂Y)(X) ⍝ Zeichne Kurve
[62]
[63] ⍝ Profil-Mittellinie
[64] sp.LineGraphStyle←Causeway.LineGraphStyles.AnnotateModel
[65] sp.SetLineStyles⊂Causeway.LineStyle.(Solid)
[66] sp.SetPenWidths⊂,0.5
[67] sp.SetColors⊂System.Drawing.Color.(Green)
[68] sp.DrawLineGraph(,⊂0 0)(0 1)
[69]
[70] ⍝ Markierung eines Punktes
[71] sp.LineGraphStyle←Causeway.LineGraphStyles.(NoLines+Markers)
[72] sp.SetMarkers(Marker.Bullet)
[73] sp.SetMarkerScales⊂,3
[74] sp.DrawLineGraph(,⊂,0)(,ProfPara[1;2])
[75] sp.SetKeyText⊂'ProfPara[2;1]'
[76]
[77] ⍝ Chart2 (Table 1) Profilparameter ============================================================================
[78] sp.SetTablePosition(0.84)(0.4)(0)(0) ⍝ Position der Tabelle 1
[79]
[80] sp.Heading←'Profilparameter'
[81] sp.SetHeadingFont'Times' 10 System.Drawing.FontStyle.Regular System.Drawing.Color.Navy
[82] sp.HeadingStyle←Causeway.HeadingStyles.NoWrap
[83]
[84] sp.TableStyle←Causeway.TableStyles.Shadowed ⍝ zeichnet Schatten unter das Feld
[85] sp.XAxisStyle←Causeway.XAxisStyles.GridLines
[86] sp.YAxisStyle←Causeway.YAxisStyles.GridLines
[87] sp.YCaption←''
[88] sp.SetXLabels⊂,¨'Bez.' 'Wert'
[89] sp.DrawTable⊂,¨,∘⍕¨¨↓⍉ProfPara
[90]
[91] ⍝ Chart3 (Table 2) Profilkoordinaten ===========================================================================
[92] sp.SetTablePosition(1.01)(0.4)(0)(0) ⍝ Position der Tabelle 2
[93]
[94] sp.Heading←'Profilkoordinaten'
[95] sp.SetHeadingFont'Times' 10 System.Drawing.FontStyle.Regular System.Drawing.Color.Navy
[96] sp.HeadingStyle←Causeway.HeadingStyles.NoWrap
[97]
[98] sp.TableStyle←Causeway.TableStyles.Shadowed ⍝ zeichnet Schatten unter das Feld
[99] sp.XAxisStyle←Causeway.XAxisStyles.GridLines
[100] sp.YAxisStyle←Causeway.YAxisStyles.GridLines
[101] sp.ValueTagFormat←'##0.0000'
[102] sp.SetXLabels⊂,¨'X' 'Y1' 'Y2'
[103] sp.DrawTable⊂↓⍉XYY
[104]
[105] ⍝ Textfeld mit Rand ============================================================================================
[106] sp.NoteStyle←Causeway.NoteStyles.(Boxed+Rounded)
[107] sp.SetNoteBackground(Color.Goldenrod)
[108] sp.SetNoteFont'Arial' 12 System.Drawing.FontStyle.Regular System.Drawing.Color.Green
[109] sp.DrawNote('Text mit Rand: X=0.1, Y=0.2, H=0.0, B=0.3' 0.1 0.2 0 0.3)
[110]
[111] ⍝ Textfeld ohne Rand ===========================================================================================
[112] sp.NoteStyle←0
[113] sp.SetNoteBackground(Color.WhiteSmoke)
[114] sp.SetNoteFont'Arial' 12 System.Drawing.FontStyle.Regular System.Drawing.Color.Brown
[115] sp.DrawNote('Text ohne Rand: X=0.0, Y=0.45, H=0.0, B=0.3' 0 0.45 0 0.3)
[116]
[117] ⍝ = Output =============================================================================
[118] ⍝ - Graphic in *.png - write file ------------------------------------------------------
[119] ⍝ sp.SaveImage'D:\DyalogAPL\ws3_Dat\Dprofil1.png'System.Drawing.Imaging.ImageFormat.Png
[120] ⍝ - Graphic in *.pdf - write file ------------------------------------------------------
[121] sp.SavePdf⊂'D:\DyalogAPL\ws3_Dat\DProfil1.pdf'
[122] ⍝ - Graphic on screen show -------------------------------------------------------------
[123] viewer←⎕NEW SharpPlotViewer
[124] viewer.SharpPlot←sp
[125] viewer.Show ⍬
[126] ⍝ ======================================================================================

One more question about DProfil1:
How to mark the green dot within the profile with reference arrow and caption (for example "XDMAX")?

Best regards
Leo
Leo
 
Posts: 14
Joined: Mon Sep 18, 2017 12:10 pm


Return to Language

Who is online

Users browsing this forum: No registered users and 3 guests