Trying to remove the gridlines and background in a PCA using ggbiplot in R - pca

I have made a PCA in R using
ggbiplot(PCA.model,ellipse=TRUE,labels=PCA_data
$label,groups=PCA_data$Month)
[image of PCA][1]
but i need to remove the grey and the gridlines. I have tried solutions on here but nothing has worked so far.
I have tried this and various other themes but no luck.
ggbiplot(PCA.model,ellipse=TRUE,labels=PCA_data
$label,groups=PCA_data$Month, frame.colour = NULL)
$label,groups=PCA_data$Month) + theme_classic()
Any ideas? :)
[1]: https://i.stack.imgur.com/ADIn9.png

it works for me with the following commands:
theme_set(theme_bw()) + theme( plot.background = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank())
theme_set(theme_bw()) #To make the gray background white
theme( plot.background = element_blank(), panel.grid.major = element_blank(), panel.grid.minor = element_blank()) #Eliminate the grids

Related

How to insert sidebarLayout/sidebarPanel in shiny dashboard?

I've been creating a shiny app and now I want to reproduce it in shiny dashboard without success so far. My main question is if sidebarLayout/sidebarPanel works inside dashboardSidebar? I'm having this error message: Expected an object with class 'shiny.tag'. Does anyone know what is this error about? Thanks a lot!!
Here is my ui.R
ui = dashboardPage(
dashboardHeader(title="Deteccao de arvores individuais de LiDAR em Shiny App - R", align="center"),
dashboardSidebar(
sidebarMenu(
menuItem("Defina seus parametros e preferencias")),
sidebarLayout(
sidebarPanel(
fileInput('layer', 'Select the CHM.asc file', multiple=FALSE, accept='asc', width = "350px"),
selectInput("fws", "Select the size of windows to find trees", choices = c("3x3"= (fws<-3), "5x5"= (fws<-5), "7x7"= (fws<-7)), width = "350px"),
wellPanel(checkboxInput("checkbox", "Would you like to apply the smoothing model for canopy?", value = FALSE, width = "350px"), selectInput("sws", "Select the size of the smoothing window for trees", choices = c("3x3" = (sws<-3), "5x5" = (sws<-5), "7x7"=(sws<-7)), width = "350px")),
checkboxInput("checkp", "Plot individual trees detected in CHM", value=FALSE, width="350px"),
checkboxInput("checkpd", "Download the shapefile (.shp) of Individual trees detected", value = FALSE, width = "350px"), uiOutput("shapefile"),
actionButton("action", "RUN!")))
),
dashboardBody(
fluidRow(
tabBox(side="right", height = "500px",
tabPanel("Visualization of CHM", plotOutput("mapPlot")),
tabPanel("Trees detected from rLiDAR", tableOutput("arvlist"), downloadButton("downList", "Download Tree List")),
tabPanel("Summary of LiDAR metrics", tableOutput("sumy"), downloadButton("downSumy", "Download Summary of LiDAR metrics")),
tabPanel("Profile of height model", plotOutput("hist"), downloadButton("downHist", "Download Height's Histogram of Density")), #histograma de densidade
tabPanel("Individual trees detected - Model 2D of CHM", plotOutput("plotTrees"), downloadButton("downDetec", "Download CHM of Trees Detected"))
)
))
)

Change fontsize of colorbars in matplotlib

I am having difficulty adjusting the font size of the ticks on the colorbar in the following code.
fig = plt.figure(figsize=(10,6))
ax = fig.add_subplot(111)
im = ax.pcolor(np.ma.masked_invalid(np.roll(lon, -1100, axis=1)[:2100, :3500]),
np.ma.masked_invalid(np.roll(lat, -1100, axis=1)[:2100, :3500]),
np.ma.masked_invalid(np.roll(np.absolute(zeta_Mar), -1100, axis=1)[:2100, :3500]),
cmap='Reds', norm=colors.LogNorm(vmin=1e-6, vmax=1e-4))
ax.set_xlabel('Longitude', fontsize=14)
ax.set_xlabel('Latitude', fontsize=14)
cbar_axim = fig.add_axes([0.95, 0.15, 0.03, 0.7])
cbar = fig.colorbar(im, cax=cbar_axim, ticks=[1e-6, 1e-5, 1e-4])
cbar.set_ticklabels([r'$-10^{-6}$', r'$10^{-5}$', r'$10^{-4}$'])
cbar.set_label(r'$\zeta\ [s^{-1}]$', fontsize=16)
plt.show()
Could anyone tell me the correct syntax to include the fontsize argument?
use cbar.ax.tick_params(labelsize=10)
From here and here
If I use #Yugi's answer, I will get latex errors. You can also set the fontsize with:
ticklabs = cbar.ax.get_yticklabels()
cbar.ax.set_yticklabels(ticklabs, fontsize=10)
If you are trying to increase the font size but some numbers disappear because of big size, you can do
cbar = plt.colorbar()
for t in cbar.ax.get_yticklabels():
t.set_fontsize(20)

getting the value to the Entry using tkinter

I want to know how to display the values using Entry? i mean for instance if i have a function like:
def open():
path=tkFileDialog.askopenfilename(filetypes=[("Image File",'.jpg')])
blue, green, red = cv2.split(path)
total = path.size
B = sum(blue) / total
G = sum(green) / total
R = sum(red) / total
B_mean1.append(B)
G_mean1.append(G)
R_mean1.append(R)
blue.set(B_mean1)
green.set(G_mean1)
red.set(R_mean1)
root = Tk()
blue_label = Label(app,text = 'Blue Mean')
blue_label.place(x = 850,y = 140)
blue = IntVar(None)
blue_text = Entry(app,textvariable = blue)
blue_text.place(x = 1000,y = 140)
green_label = Label(app,text = 'Green Mean')
green_label.place(x = 850,y = 170)
green = IntVar(None)
green_text = Entry(app,textvariable = green)
green_text.place(x = 1000,y = 170)
red_label = Label(app,text = 'Red Mean')
red_label.place(x = 850,y = 200)
red = IntVar(None)
red_text = Entry(app,textvariable = red)
red_text.place(x = 1000,y = 200)
button = Button(app, text='Select an Image',command = open)
button.pack(padx = 1, pady = 1,anchor='ne')
button.place( x = 650, y = 60)
root.mainloop()
I have specified all the necessary imports and list variables. Still the value is not being displayed in the Entry field.
like if i get the value as :
blue mean = 37,
green mean = 36,
red mean = 41
and it will print in the console but not in the window. How can I achieve this?
Any suggestions are welcome!
Thanks for your supports!
Firstly I want to recommend that instead of using the place method you use the grid method. It is a lot faster and allows you to do things in a much more orderly fashion - especially in this application. Note that there are other geometry managers - like pack - which are good in yet other instances. Anyways, your GUI:
root = Tk()
blue_label = Label(root, text="Blue mean:")
blue_label.grid(row=1, column=1, sticky="w")
blue_entry = Entry(root)
blue_entry.grid(row=1, column=2)
green_label = Label(root, text="Green mean:")
green_label.grid(row=2, column=1, sticky="w")
green_entry = Entry(root)
green_entry.grid(row=2, column=2)
red_label = Label(root, text="Red mean:")
red_label.grid(row=3, column=1, sticky="w")
red_entry = Entry(root)
red_entry.grid(row=3, column=2)
root.mainloop()
That makes your GUI display nicely and without the manual geometry. Note that sticky just sets how the text is justified ("w" means west, and so the text justifies left).
Now, for actually displaying the text, all you have to do is:
blue_entry.insert(0, "blue-mean-value")
green_entry.insert(0, "green-mean-value")
red_entry.insert(0, "red-mean-value")
And if you are overwriting any text that is already there just do:
blue_entry.delete(0, END) # And green_entry and red_entry

cocos2d remove tint

I'm trying to implement a highlight animation to my sprites. The sprite should highlight to a given color and gradually reverse back to its original colors, with the following code:
- (void)highlight {
CCTintTo *tintAction = [CCTintTo actionWithDuration:0.1 red:255 green:255 blue:255];
CCTintTo *tintBackAction = [tintAction reverse];
CCSequence *sequence = [CCSequence actions: tintAction, tintBackAction, nil];
[self runAction:sequence];
}
Now this function raises an exception as CCTintTo doesn't seem to implement 'reverse', which makes sense. Is there any other way to implement removal of an added tint over an interval, using a CCAction?
CCSprite's default color is ccWhite, {255, 255, 255}, so if you
want to make sprite lighter, you'll have to subclass CCSprite/write shader to use additive coloring.
Just tint it back:
CCColor3B oldColor = sprite.color;
CCTintTo *tintTo = [CCTintTo actionWithDuration:t red:r green:g blue:b];
CCTintTo *tintBack = [CCTintTo actionWithDuration:t red:oldColor.r green:oldColor.g blue:oldColor.b];
[sprite runAction:[CCSequence actions: tintTo, tintBack, nil]];
You can store previous color before start tint, then just create CCTintTo with initial RGB values.
For Cocos2dx (C++)
ccColor3B oldColor = sprite->getColor();
CCTintTo* action = CCTintTo::create(0.5f, 127, 255, 127);
CCTintTo* actionReverse = CCTintTo::create(0.5f, oldColor.r, oldColor.g, oldColor.b);;
sprite->runAction(CCSequence::create(action, actionReverse, NULL));
Works fine Kreiri, thanks! I already gave a plus to you:).

CCLayerPanZoom won't zoom in or out

I have been having trouble with CCLayerPanZoom for weeks now and finally got close but am still having an issue. I have a tile map that is quite large 8000 pixels x 8000 pixels and what I'd like to to is have the ability to zoom in to about 2.0f and zoom out to about 0.4f. The below code works great in that it lets me pan around my entire tile map and NOT pan past the edges - a common problem with CCLayerPanZoom, however the code will not allow zoom in or out. I have commented out minScale and maxScale for now since neither is working. I have tried changing the location of minScale and maxScale and it doesn't work anywhere. Does anyone have any ideas how to get minScale and maxScale to work so zooming will function?
//PanZoomLayer
_panZoomLayer = [[CCLayerPanZoom node] retain];
[self addChild: _panZoomLayer];
_panZoomLayer.delegate = self;
[_panZoomLayer addChild: _tileMap z :1 tag: kBackgroundTag];
_panZoomLayer.mode = kCCLayerPanZoomModeSheet;
_panZoomLayer.rubberEffectRatio = 0.0f;
CCNode *backgroundZ = [_panZoomLayer getChildByTag: kBackgroundTag];
CGRect boundingRect = CGRectMake(0, 0, 0, 0);
boundingRect.size = [backgroundZ boundingBox].size;
[_panZoomLayer setContentSize: boundingRect.size];
_panZoomLayer.anchorPoint = ccp(0.5f, 0.5f);
_panZoomLayer.position = ccp(0.5f * winSize.width, 0.5f * winSize.height);
_panZoomLayer.panBoundsRect = CGRectMake(0, 0, winSize.width, winSize.height);
_panZoomLayer.minScale = 0.4f;
_panZoomLayer.maxScale = 2.0f;
//end PanZoomLayer
Finally figured it out, by adding the below line to the code above the CCPanZoomLayer finally works great. Hopefully this code hopes others out that have struggled with this cocos2d extension
[[[CCDirector sharedDirector] view] setMultipleTouchEnabled:YES];