The plot library creates plots by assembling elements (such as axes and renderers) together. For example, the plot library does no have a scatter plot type, instead points can be rendered on a plot, but lines could also be rendered on the same plot. You can also control many other things, such as if axes are drawn or not, whether "tick markers" are present, where they should be placed and what their labels should be.
For example, here is a plot with only an X axis (which is not at Y = 0) and which combines a scatter plot and a function: #lang racket (require plot) (parameterize ([plot-decorations? #f]) (plot (list (function (lambda (x) (* x x))) (points (for/list ([x (in-range 50)]) (vector (- (random 20) 10) (- (random 200) 100)))) (x-axis 20 #:ticks? #t #:labels? #t)) #:x-min -10 #:x-max 10)) [image: sample-plot.PNG] The plot library has a lot of options and renderers (which are the functions that display data), but it is not extensible, in the sense that you cannot provide your own renderer without modifying the library. If you want to create a new type of renderer, this pull request shows an example: https://github.com/racket/plot/pull/26 You can of course draw a plot onto a canvas using `plot/dc` and you could draw on top of that plot using additional `dc<%>` calls, but the problem with this approach is that your code will have no information about where the actual plot area is, so you cannot reliably add elements to the plot in the plot coordinate system. Best Regards, Alex. On Thursday, December 6, 2018 at 7:22:51 AM UTC+8, Matt Jadud wrote: > > Hi all, > > If I want to develop a new plot type, would I do best to: > > 1. Build on plot, or > 2. Build on pict? > > I suspect #1. > > If I want to (say) have a number line, I would like to have an x-axis, > centered in my plot area (vertically), and no y-axis. I've been reading the > plot code for scatter plots, and I'm not clear where/how, if I were to > implement in a similar way, where I would override/parameterize for > changing the axes. (There's near and far axes (bottom and top) in 2D > renderers, but I don't seem to get to decide where they go vertically in > the plot space.) > > Then, would I be drawing to it using the utilities built into plot, or do > I convert to a dc% in some way, and leverage pict, or... ? > > In short, I feel like I should be building on plot/extending plot, I don't > want to reinvent wheels that are already invented, but I'm not yet sure > where the best starting point is. Do I develop a new plot type, dig deeper > into how axes are drawn, or do I do everything with overlays, or ...? > > Many thanks, > Matt > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.