How to find the arguments of a function in a package

I want to use the function scatter. I know that this function belongs to the package Plots or StatsPlots. I am not sure.

  1. How do I know the package where scatter is defined?
  2. How to find the arguments of scatter?
  3. Is it possible to find help about scatter in the REPL? How?
    Maybe I have a problem reading the documentation of some packages in Julia. I think that in R package documentation is more standardized but perhaps I am wrong.

methods tells you, but only if you already using the package which defines it:

julia> using Plots

julia> using StatsPlots

julia> methods(scatter)
# 1 method for generic function "scatter":
[1] scatter(args...; kw...) in Plots at C:\Users\oheil\.julia\packages\RecipesBase\92zOw\src\RecipesBase.jl:403

If you search for a function without knowing anything about it Julia can’t help in general.

First check is always ? in the REPL:

help?> scatter
search: scatter scatter! scatter3d scatter3d! scatterhist scatterhist! marginalscatter marginalscatter! AbstractPattern

  scatter(x,y)
  scatter!(x,y)

  Make a scatter plot of y vs x.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> scatter([1,2,3],[4,5,6],markersize=[3,4,5],markercolor=[:red,:green,:blue])
  julia> scatter([(1,4),(2,5),(3,6)])

Second check the documentation, if available, in this case Home · Plots
Third and Fourth, depending on your preferences:
Ask here or check the source code.

As said above using ? in the REPL (but it needs to be loaded with using)

I think you are right. The Vignette system (at least for the bioconductor project) is quite standardized and nearly always at hand. But it isn’t therefore better. It’s more like: lets have the lowest possible requirement as a standard
In R if you just have a function name and nothing else you are lost like in Julia or in every other language where a package ecosystem exists.
With some exceptions I find the documentation of Julia and many packages outstanding, despite that you have to search for it and several presentations exist.

A last hint: asking here is always beneficial and perhaps the fastest way to good results, but, of course, you need to ask in a minimal specific way :slight_smile:

5 Likes

For the first question, there is also a fun macro which opens the method definition in a text editor. For example,

@edit round(3.4)

Edit: This is just an addition to the previous comment. The edit macro is nice if documentation for a method is missing or when the documentation isn’t very clear.

2 Likes