I don't know if it is a good idea or not, but using the `Requires` package 
is one way to do this. That package's `@require` macro lets you define 
functions when another package is loaded, such as a plotting package.  A 
pattern like this can be used:

using Requires
Requires.@require PyPlot begin
    ....
end

Requires.@require Gadfly begin
    ....
end



On Thursday, January 22, 2015 at 12:20:57 PM UTC-5, David van Leeuwen wrote:
>
> Hello, 
>
> On Thursday, January 22, 2015 at 5:13:05 PM UTC+1, Simon Danisch wrote:
>>
>> Well, I'm planning to introduce some functionality similar to show, 
>> building upon a rich type system.
>> What I have in mind is something like this:
>>
>> show(::Matrix{Z}; parameters...)       => Surface
>> show(::Matrix{Red}; parameters...)   =>  Red channel
>> show(::Matrix{RGB}; parameters...) => Image
>> show(::Matrix{Vector2}; parameters...) => Vectorfield
>> show(::Vector{Y}; parameters...) => Line plot
>> show(::Vector{Point2D}; parameters...) => scatter plot
>> show(::Vector{Point3D}; parameters...) => 3D point cloud
>> show(::(Vector{Point3D}, Vector{Face}); parameters...) => mesh
>>
>> This is nice for visual debugging, but probably not sufficient for more 
>> complicated plots and annotations.
>>
>> This is cool, and I think you can do things this way because `show()` is 
> defined in Base, and defines the API. 
>
> However, the various `plot()` etc defined in modules Winston, PGFSPlots, 
> etc do not overload a `Base.plot()`, i.e., there is no API defined for the 
> most common plotting calls AFAIK.  So I am still struggling how I can 
> overload a `plot()` without `using` a specific plotting module like 
> Winston, PGFSPlots in my module---because I want to leave that choice to 
> the user. 
>
> ---david
>  
>
>> Am Donnerstag, 22. Januar 2015 16:42:37 UTC+1 schrieb David van Leeuwen:
>>>
>>> Hello, 
>>>
>>> I've just read up on most recent conversations mentioning plotting, 
>>> after I went through a similar install-and-try-out cycle for the various 
>>> plotting packages. 
>>>
>>> I am busy with a package named ROC <https://github.com/davidavdav/ROC> 
>>> (Receiver 
>>> Operating Characteristic).  It is mostly about decision cost functions and 
>>> efficiently computing ROC statistics, but there is also some support for 
>>> making various plots related to the ROC. 
>>>
>>> I do not want to decide for a potential user of this package which 
>>> plotting package she should use.  So it would be nice if there would be an 
>>> abstract plotting API (I suppose this does not exist yet). 
>>>
>>> Supposing that it is possible to make an API that includes some common 
>>> plotting primitives, and that makes a runtime selection based on 
>>> `isdefined(plottingpackagename)`, how would you 
>>>  - overload a function, typically `plot()`, when at module-include time 
>>> it is not yet known which plotting package the user wants
>>>  - specify the dependence of this package to any one of the available 
>>> plotting packages.  
>>>
>>> Thoughts?
>>>
>>> Thanks, 
>>>
>>> ---david
>>>
>>

Reply via email to