Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creating empty plot #751

Closed
joachimdahl opened this issue Nov 19, 2015 · 4 comments · Fixed by #1392
Closed

creating empty plot #751

joachimdahl opened this issue Nov 19, 2015 · 4 comments · Fixed by #1392

Comments

@joachimdahl
Copy link

I am generating sparsity plots as

plot(x=[1:10;],y=[1:10;],Guide.xticks(ticks=[1,10]),Guide.yticks(ticks=[1,10]))

and sometimes the underlying matrices happen to be zero, and I think this is a corner-case missing from plot(), e.g.,

julia> plot(x=[],y=[],Guide.xticks(ticks=[1,10]),Guide.yticks(ticks=[1,10]))
ERROR: BoundsError: attempt to access 0-element Array{Any,1}
  at index [1]
 in first at abstractarray.jl:63
 in apply_statistic at /home/joachim/.julia/v0.4/Gadfly/src/statistics.jl:777
 in apply_statistics at /home/joachim/.julia/v0.4/Gadfly/src/statistics.jl:38
 in render_prepare at /home/joachim/.julia/v0.4/Gadfly/src/Gadfly.jl:676
 in render at /home/joachim/.julia/v0.4/Gadfly/src/Gadfly.jl:717
 in draw at /home/joachim/.julia/v0.4/Gadfly/src/Gadfly.jl:821
@bjarthur
Copy link
Member

a similar corner case which errors out is when all(isnan,y)==true

@acrosby
Copy link

acrosby commented Dec 19, 2017

Any progress on this, or a clever work around? Thanks!

@kilianbreathnach
Copy link

I've managed to use hstack and vstack to make an array of subplots with empty space in place of certain axes with this hack:

subplots = Array{Gadfly.Plot, 1}(9)

for i in 1:9

    <...>

    if (<"some condition">)
        subplots[i] = plot(x=[0,1], y=[0,1], Geom.point,
                           Guide.xticks(ticks=nothing), Guide.yticks(ticks=nothing),
                           Guide.xlabel(nothing), Guide.ylabel(nothing),
                           Theme(default_color="white"))
        end

    <...>

end

fig = vstack(hstack(subplots[1:3]), hstack(subplots[4:6]), hstack(subplots[7:9]))

So basically just a plot of white points with no axes or labels.

@bjarthur
Copy link
Member

bjarthur commented Feb 8, 2018

i think the original poster was hoping to have <some condition> checked for automatically. to leave a panel blank, it's easiest to just use context(), as described here.

@Mattriks Mattriks mentioned this issue Nov 12, 2019
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants