How to rotate the x-axis labels 90 degrees in levelplot
As far as the rotation of the x-axis labels go, you have to use parameter scales
(see ?xyplot
for more information on lattice
parameters). You want to modify only its x
component: scales=list(x=list(rot=90))
. In context:
levelplot(cor2,
aspect="iso", scales=list(x=list(rot=90)),
main="Correlation Matrix", col.regions=rgb.palette(120),
cuts=100, at=seq(0,1,0.01))
Rotating axis labels in lattice() package - R
you can try this using rot
instead of las
levelplot(matrix(runif(100),10,10), scales=list(y=list(rot=45), x=list(rot=45)))
Rotate label text in seaborn factorplot
You can rotate tick labels with the tick_params
method on matplotlib Axes
objects. To provide a specific example:
ax.tick_params(axis='x', rotation=90)
How to change the breaks in date axis + rotate them 90 degrees
Use axis.timeDate
with las=2
like this:
library(timeSeries)
tt <- timeSeries(seq(10,70,10), as.Date("2000-01-10") + 0:6)
plot(tt, axes = FALSE)
box()
ok <- as.numeric(format(time(tt), "%w")) %in% 0:2
axis.timeDate(1, at = time(tt)[ok], format = "%a", las = 2)
Rotate Y-axis categorical label in Seaborn plot?
Most stackoverflow answers would recommend using ax.set_yticklabels(rotation = 90)
, while this does work, it also requires you to provide the positional parameter labels
(failing to provide this will give you a TypeError
). I'd recommend using plt.yticks(rotation = 90)
. This is how it'd look:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(y="day", x="total_bill", data=tips)
plt.yticks(rotation = 90)
plt.show(ax)
Adjusting font size of axis labels in levelplot function in R
And THE WINNER IS:
pdf('corr.pdf')
data <- read.table("test", header=T)
z <- cor(data)
heatmap.2(z, Rowv=FALSE, Colv=FALSE, dendrogram="none",
key=TRUE, density.info="none", trace="none",
col=colorpanel(100, lowColor, highColor), scale="none",cexRow=0.3, cexCol=0.3 )
dev.off()
Diagonal labels orientation on x-axis in heatmap(s)
To fix pheatmap
, all you really want to do is to go into pheatmap:::draw_colnames
and tweak a couple of settings in its call to grid.text()
. Here's one way to do that, using assignInNamespace()
. (It may need additional adjustments, but you get the picture ;):
library(grid) ## Need to attach (and not just load) grid package
library(pheatmap)
## Your data
d <- matrix(rnorm(25), 5, 5)
colnames(d) = paste("bip", 1:5, sep = "")
rownames(d) = paste("blob", 1:5, sep = "")
## Edit body of pheatmap:::draw_colnames, customizing it to your liking
draw_colnames_45 <- function (coln, ...) {
m = length(coln)
x = (1:m)/m - 1/2/m
grid.text(coln, x = x, y = unit(0.96, "npc"), vjust = .5,
hjust = 1, rot = 45, gp = gpar(...)) ## Was 'hjust=0' and 'rot=270'
}
## For pheatmap_1.0.8 and later:
draw_colnames_45 <- function (coln, gaps, ...) {
coord = pheatmap:::find_coordinates(length(coln), gaps)
x = coord$coord - 0.5 * coord$size
res = textGrob(coln, x = x, y = unit(1, "npc") - unit(3,"bigpts"), vjust = 0.5, hjust = 1, rot = 45, gp = gpar(...))
return(res)}
## 'Overwrite' default draw_colnames with your own version
assignInNamespace(x="draw_colnames", value="draw_colnames_45",
ns=asNamespace("pheatmap"))
## Try it out
pheatmap(d)
Related Topics
Using R to Fit a Sigmoidal Curve
Create Multiple Data Frames from One Based Off Values with a for Loop
Colons Equals Operator in R? New Syntax
R Ggplot Boxplot: Change Y-Axis Limit
Rcpp Function Calling Another Rcpp Function
How to Save Interactive Charts from Dygraph
Clustered Standard Errors in R Using Plm (With Fixed Effects)
Setting Hex Bins in Ggplot2 to Same Size
Exporting R Regression Summary for Publishable Paper
Access Data Frame Column Using Variable
Combined Line & Bar Geoms: How to Generate Proper Legend
Add Missing Value in Column with Value from Row Above
How to Find Previous Sunday in R
Ggplot2: Coloring Axis Text on a Faceted Plot
Applying the Optim Function in R in C++ with Rcpp
Match.Call with Default Arguments
Datatable Is Not Printed in Combination with Cat Command in Rmd/Rstudio