GithubHelp home page GithubHelp logo

Plotting outside of the plot area about proc HOT 3 CLOSED

xrobin avatar xrobin commented on July 19, 2024
Plotting outside of the plot area

from proc.

Comments (3)

xrobin avatar xrobin commented on July 19, 2024

One can produce lines outside the plotting area with code like:

roc1 <- roc(aSAH$outcome, aSAH$wfns)
roc2 <- roc(aSAH$outcome, aSAH$ndka)
par(mar=c( 4, 4.5, 1, 1 ))
opa <- par(mar=c(4, 4, 2, 2) + 0.1, mgp = c(2.5, 1, 0))
plot(roc1$specificities, roc1$sensitivities, xlim=c(0.96, 0.66), ylim=c(0.5,0.86), xaxt="n", type="l")
par(opa)
lines(roc2$specificities, roc2$sensitivities)
axis(side=1)

The question remains: why in the previous example the "out of the area" plotting happens only when axis is called between the two calls to plot - it is clearly not the case in this example.

from proc.

xrobin avatar xrobin commented on July 19, 2024

This is pretty much a minimum reproducible example:

x <- y <- 1:10
smallmar <- rep(0, 4)
bigmar <- c(4, 4, 2, 2)
par(mfrow=c(2, 1))

# First plot outside area
par(mar=bigmar)
plot(x, y, type="n") # l or n doesn't matter - use l to avoid re-plotting
lines(x, y)
par(mar=smallmar)
axis(side=1)
lines(x + 1, y)

# Second plot stays within plot area
par(mar=bigmar)
plot(x, y, type="n")
lines(x, y)
par(mar=smallmar)
lines(x + 1, y)
axis(side=1)

Looks like a bug upstream. If I call axis between the two calls to lines the line extends outside the plot area. It could be a weird clipping effect as described in ?clip: "Exactly when the clipping region will be reset can be hard to predict".

from proc.

xrobin avatar xrobin commented on July 19, 2024

Long story short, plotting outside the previous plotting area seems to be the normal behaviour when margins are updated (but one has to call axis or box to have it enforced) - after all the plotting area is updated. I do think there is nothing to change here.

Please feel free to re-open if you think otherwise.

from proc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.