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 6568241
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T14:27:12+00:00 2026-05-25T14:27:12+00:00

I am using R to plot trying to conditionally change parts of an array

  • 0

I am using R to plot trying to conditionally change parts of an array
based on the columns of the array.

I have worked out the following steps:

x<-array(1,dim=c(4,4,3))
r<-x[,,1]
g<-x[,,2]
b<-x[,,3]

r1<-apply(r[,2:3],1:2,function(f){return(0)})
g1<-apply(g[,2:3],1:2,function(f){return(0)})
b1<-apply(b[,2:3],1:2,function(f){return(0)})

r3<-cbind(r[,1],r1,r[,4])
g3<-cbind(g[,1],g1,g[,4])
b3<-cbind(b[,1],b1,b[,4])

# Pass to pixmapRGB

This works, but as I am new to R, I was wondering if
there was a more efficient way to manipulate parts
of an array.

For example, does apply know which element it is working on?

The bigger picture is that I want to graph a time-series scatter
plot over many pages.

I would like to have a thumbnail in the corner of the page that is
a graph of the whole series. I would like to color a portion of
that thumbnail a different color to indicate what range the
current page is examining.

There is alot of data, so it is not feasible to redraw a new plot
for the thumbnail on every page.

What I have done is to first write the thumbnail plot out to a tiff file.
Then I read the tiff file back in, used getChannels from pixmap
to break the picture into arrays, and used the above code to change
some of the pixels based on column.
Finally I then print the image to a viewport using
pixmapRGB/pixmapGrob/grid.draw

It seems like alot of steps. I would be grateful for any pointers
that would help me make this more efficient.

  • 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-25T14:27:13+00:00Added an answer on May 25, 2026 at 2:27 pm

    Maybe I don’t understand your question, but if what you’re trying to do is just “change some pixels based on column,” why don’t you just use the basic array indexing to do that?

    This will do the same thing you have posted:

    x<-array(1,dim=c(4,4,3))
    r<-x[,,1]
    g<-x[,,2]
    b<-x[,,3]
    r[,2:3]=0
    g[,2:3]=0
    b[,2:3]=0
    

    Is that helpful?

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

Sidebar

Related Questions

I have a a stacked bar plot using ggplot for which I'm trying to
I'm trying to plot heatmap in ggplot2 using csv data following casbon's solution in
I'm using Python to plot a couple of graphs and I'm trying to change
As question, I am trying to create a plot using the following code: chart.demo.sex.age
I'm trying to show a contour plot using matplotlib from a complex array. The
I have a bunch of points that I am trying to plot using matplotlib.
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Im using core-plot for my graphing component of my iPhone app, and I have
I have one y variable, which I am trying to plot against two related
I am trying to create plot some push pins on map using GeoCoordinate as

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.