Re: [Ocaml-gnuplot-devel] plotitems, tags and global style setting
Status: Beta
Brought to you by:
chris_77
From: Christophe T. <chr...@us...> - 2004-08-12 16:52:42
|
Hi Viktor, Good to read you again! On Thu, 12 Aug 2004, Viktor Tron <v....@ed...> wrote: > > On Wed, 11 Aug 2004 16:03:33 +0200 (CEST), Christophe TROESTLER <chr...@us...> wrote: > > > It as also good practice for the one who will interpret the plots > > because it creates visual unity. > ?? What I meant is that by default pltting the same data with the same style is what an author should want because the style will be the visual identity of the data across possibly different plots. Therefore, plotting-data-with-the-same-style should be straightforward while one can require a bit more verbosity for style changes. > > An intermediate solution would be to create a [decorations] > > (independent of the [handle]) type that would be passed around. > > But maybe this is a bit overkill... > > This is the only 'normal' solution I can see at the moment. So let's dig a bit more that idea. The good side is more referential transparency and the fact that one can now add an optional argument to [tics], [border],... to easily set their style (it was possible but maybe a bit cumbersome before). The problem is: how do we create these and are they mutable? Do we write let st = P.pen ~st 3 in (where [st] is an optioal argument that defaults to a "default style" -- thus allowing the creation of new styles without needing new commands) or P.pen st 3 which requires a [let st = Style.create() in] to be issued before? > >> ON TAGS > It has to be mutable since they are remembered by viewports? Yes. If it is not mutable, viewports will have to replace the old plotitem list by the new one. > This whole thing look quite appealing, but a difference to what I > proposed is that now. the same decorated plotitems can be plotted > on two viewports. And if it is removed from one of them, then we > shouldn't delete the data (cause it may need to replot on another). That's right but in order to be able to replot the data, the handle will keep a "reference" to it so it (or its name in case of files) will still be accessible (hidden in the [handle] data-structure). > But the data is not 'shared' between two plotitems but it is the > very same plotitem (included in the viewport's history). The point is: the data is reachable. If you read the info for [Gc.finalise], you will see that in order for the finalisation function to be called, the value must become unreachable first. The idea is to use the data string (or the filename string) as the finaliser holder. There is a difficulty though. The data is not linked anymore to session [handle]s, so when a session closes, one cannot remove the data files. Thus a cleaning function will need to be registered [at_exit]. But the problem is that we cannot use a global data-structure (or else with mutexes) since I want the library to be thread safe... But maybe a global variable with mutexes is the way to go because one would also like to create new directories every 10000 files or such for speed (worth of that to be confirmed). ChriS |