Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7178955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:01:58+00:00 2026-05-28T17:01:58+00:00

Is there a workaround to set the color when using plot.xts ? This bug

  • 0

Is there a workaround to set the color when using plot.xts?

This bug (still present in 0.8.2) makes it impossible. I know I could use plot.zoo but I was wondering if there was a cleaner solution since that bug doesn’t look like is going to get fixed any time soon 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:01:59+00:00Added an answer on May 28, 2026 at 5:01 pm

    Here’s a patched version. I had to export is.OHLC from xts to make it work. I hope there are no side effects. I added an argument col and passed it to plot explicitly.

    plot.xts2 <- function (x, y = NULL, type = "l", auto.grid = TRUE, major.ticks = "auto", 
        minor.ticks = TRUE, major.format = TRUE, bar.col = "grey", 
        candle.col = "white", ann = TRUE, axes = TRUE, col = "black", ...) 
    {
        series.title <- deparse(substitute(x))
        ep <- axTicksByTime(x, major.ticks, format = major.format)
        otype <- type
        if (xts:::is.OHLC(x) && type %in% c("candles", "bars")) {
            x <- x[, xts:::has.OHLC(x, TRUE)]
            xycoords <- list(x = .index(x), y = seq(min(x), max(x), 
                    length.out = NROW(x)))
            type <- "n"
        }
        else {
            if (NCOL(x) > 1) 
                warning("only the univariate series will be plotted")
            if (is.null(y)) 
                xycoords <- xy.coords(.index(x), x[, 1])
        }
        plot(xycoords$x, xycoords$y, type = type, axes = FALSE, ann = FALSE, 
            col = col, ...)
        if (auto.grid) {
            abline(v = xycoords$x[ep], col = "grey", lty = 4)
            grid(NA, NULL)
        }
        if (xts:::is.OHLC(x) && otype == "candles") 
            plot.ohlc.candles(x, bar.col = bar.col, candle.col = candle.col, 
                ...)
        dots <- list(...)
        if (axes) {
            if (minor.ticks) 
                axis(1, at = xycoords$x, labels = FALSE, col = "#BBBBBB", 
                    ...)
            axis(1, at = xycoords$x[ep], labels = names(ep), las = 1, 
                lwd = 1, mgp = c(3, 2, 0), ...)
            axis(2, ...)
        }
        box()
        if (!"main" %in% names(dots)) 
            title(main = series.title)
        do.call("title", list(...))
        assign(".plot.xts", recordPlot(), .GlobalEnv)
    }
    
    plot.xts2(as.xts(sample_matrix[,1]), col = "blue")
    

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any workaround for the following 1 pixel to the left bug? <!DOCTYPE
Is there a workaround for Internet Explorer to implement the functionality offered by 'this'
Update: See the bottom of this question for a C# workaround. Hi there, Consider
The WinForms ProgressBar control allows its foreground color to be set. While this normally
This code draws a single color (with alpha) shape using a bitmap's alpha channel.
Is there any workaround to allow actionscript3 write to file system without adobe air?
Is there any Workaround/Tool for renaming the Resource Keys from the resource file .
Is there a fix or a workaround for the memory leak in getpwnam?
Why can't you do this and is there are work around? You get this
Is there a workaround for the missing x:Shared MarkupExtension in silverlight? I have the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.