The APL Orchard

apl.chat ― Learn, teach, ask, code, golf, & discuss usage. See ...
Nic
Jul 28, 2020 12:44
@Adám I like "whence"
Nic
Jul 21, 2020 15:22
@Adám the Russel paradox idiom !!! worth a one-liner wednesday
Nic
Jul 21, 2020 15:22
@Adám nice one !
Nic
Jul 21, 2020 15:21
tally←⌈/⍳⍨ ⍝ ⎕IO←1
Nic
Jul 21, 2020 15:19
in ⎕IO←0 :
tally←⍳∘'a' ⍝ for numeric vectors again
Nic
Jul 21, 2020 15:17
@xpqz I'm trying to get rid of the + but I'm failing
Nic
Jul 21, 2020 15:15
tally←+.*∘0
Nic
Jul 21, 2020 15:09
tally←+/1⍨¨
tally←+.(⊢¨)∘1
Nic
Jul 14, 2020 15:08
@Adám yup and sprinters will object that it's faster because you're doing the second search in a smaller set, whereas the first formula does the two search operations on the original set
Nic
Jun 30, 2020 15:57
Cheers !
Nic
Jun 30, 2020 15:57
I have to run now.
Nic
Jun 30, 2020 15:56
Yup. Congratulations for keeping it alive !
Nic
Jun 30, 2020 15:55
ok
Nic
Jun 30, 2020 15:55
I don't have a good idea. When I look at the list of previous lessons it sounds pretty complete
Nic
Jun 30, 2020 15:55
Maybe there should be some kind of vote system for people to chose topics that matter to them ?
Nic
Jun 30, 2020 15:53
You're welcome. If you need any more help with charting, don't hesitate to ask : nicolas at dyalog dot com
Nic
Jun 30, 2020 15:52
Shall we call it a day ?
Nic
Jun 30, 2020 15:49
You can't do these kind of things with OO charting packages - unless they have a much more complex API - which is then probably largely undocumented - e.g. Syncfusion
Nic
Jun 30, 2020 15:48
Have a look at sharpplot.com/Multiplots.htm to see how powerful state machines can be.
Nic
Jun 30, 2020 15:47
It may appear old-fashioned in the days of OO API, but it's in fact VERY powerful.
Nic
Jun 30, 2020 15:47
It's not possible to "undo" something
Nic
Jun 30, 2020 15:47
@RGS That's because SharpPlot is fundamentally a state machine. Its philosophy is that of PostScript. 1. Set up paramaters 2. draw 3. back to step 1
Nic
Jun 30, 2020 15:45
which, again, is 1+International Day Number
Nic
Jun 30, 2020 15:45
in .Net you can also use System.DateTime.ToOADate
https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tooadate?view=netcore-3.1
Nic
Jun 30, 2020 15:44
@Adám Ah I get it now. it's "serial number" that I didn't undersrtand.
Nic
Jun 30, 2020 15:43
@RGS you can add a Y-zone in Adam's graph by doing
sp.SetYZones ⎕NEW Causeway.Zone(2 3 System.Drawing.Color.Orange Causeway.FillStyle.GradientTop)
before the sp.DrawLineGraph
Nic
Jun 30, 2020 15:41
Adam;Causeway;System;dates;sp;values
dates←(2020 1 1)(2020 1 31)(2020 2 1)
values←3 1 4

dates←1+{2 ⎕NQ'.' 'DateToIDN'⍵}¨dates ⍝ 1+ because microsoft invented 1900-02-29

'InitCauseway' 'View'⎕CY'sharpplot'
InitCauseway ⍬
sp←⎕NEW Causeway.SharpPlot
sp.XAxisStyle←Causeway.XAxisStyles.Date
sp.XDateFormat←'dd-MMM-yy'
sp.DrawLineGraph values dates

View sp
Nic
Jun 30, 2020 15:36
@Adám I don't get it. Can you show me a repro ?
Nic
Jun 30, 2020 15:34
@RGS Sure. All the suffering in the charting industry comes from the vast world of possible configurations.
Nic
Jun 30, 2020 15:33
@Adám Do you mean the fact that some ticks don't have labels ? That's to avoid label collision. The easy fix is to use angled labels ( sharpplot.com/AngledLabels.htm )
Nic
Jun 30, 2020 15:30
Actually it's only half a typo because VML has been abandoned by Microsoft decades ago and now has no support whatsoever
Nic
Jun 30, 2020 15:29
It's a typo =)
Nic
Jun 30, 2020 15:28
If you don't have "real" questions, you might as well the browse the doc
Nic
Jun 30, 2020 15:28
Simple examples for each chart type : sharpplot.com/Charts.htm
Nic
Jun 30, 2020 15:26
The amount of questions makes me think that we're done with charting aren't we ?
Nic
Jun 30, 2020 15:26
And for the documentation : sharpplot.com
Nic
Jun 30, 2020 15:25
I you want an overview of SharpPlot and of the available chart types, you can also look at :
https://dyalog.tv/Dyalog13/?v=Xo3vRQMaPxo
Nic
Jun 30, 2020 15:06
Nic
Jun 30, 2020 15:06
You should get something like that :
Nic
Jun 30, 2020 15:04
In a proper application, there would be two functions : one to build the data from source, one to plot it. But I thought it would be simpler to have a single big function here
Nic
Jun 30, 2020 15:04
{sp}←OwidCovidData;Causeway;Drawing;InitCauseway;System;View;cdata;cfields;codes;countries;countries_to_plot;csv;data;date;dates;emptyrow;fdata;field;fields;fields_to_plot;location;locations;miss;numfields;row;sp;txtfields;values
miss←¯1E300 ⍝ missing value

⎕SE.SALT.Load'HttpCommand'
csv←(HttpCommand.Get'https://covid.ourworldindata.org/data/owid-covid-data.csv').Data
csv←⎕CSV csv'S'
fields←csv[1;] ⋄ csv←1↓csv
txtfields←'iso_code' 'continent' 'location' 'date' 'tests_units'
date←csv[;fields⍳⊂'date']
Nic
Jun 30, 2020 15:01
I can also show a little function I wrote to plot the Covid data from a live data feed
Nic
Jun 30, 2020 15:01
Do you have no questions ?
Nic
Jun 30, 2020 15:00
I don't have a story to tell. If I wanted to provide general guidelines about chart that would be a webinar.
Nic
Jun 30, 2020 14:50
You can also grab the svg source directly in APL (without writing to file) by doing
sp.RenderSvg Causeway.SvgMode.FixedAspect
Nic
Jun 30, 2020 14:50
Yes, View is usually for development. Once you're happy with the chart, you can output it to file by doing
`sp.SaveSvg '/tmp/chart.svg' Causeway.SvgMove.FixedAspect
Nic
Jun 30, 2020 14:49
SharpPlot is greatly influenced by Tufte's recommendations ( en.wikipedia.org/wiki/Edward_Tufte )
Nic
Jun 30, 2020 14:48
This is more general, hence less appropriate for this chat room. But if there are no other questions, let's do it !
Nic
Jun 30, 2020 14:46
We might also discuss which chart type is appropriate for which data (if you have data to submit)