热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

用ggplot2中的纺织品填充条形图[复制]-Fillingbarsinbarplotwithtextilesinggplot2[duplicate]

Thisquestionalreadyhasananswerhere:这个问题在这里已有答案:Howtoaddtexturetofillcolors

This question already has an answer here:

这个问题在这里已有答案:

  • How to add texture to fill colors in ggplot2? 4 answers
  • 如何在ggplot2中添加纹理来填充颜色? 4个答案
test <- data.frame(a=c(1,2,3,4), b=c(4,4,4,4))
ggplot(test, aes(x=a, y=b, fill=factor(a)))+geom_bar(stat='identity')

enter image description here

but i also want to add texitiles in this plot, something like:
enter image description here

但我也想在这个情节中添加texitiles,例如:

Thank you very much

非常感谢你

1 个解决方案

#1


13  

Hey folks here's a wee hack that addresses the texture issue in a very basic fashion:

嘿,伙计们这里是一个小小的黑客,以一种非常基本的方式解决纹理问题:

ggplot2: make the border on one bar darker than the others using R

ggplot2:使用R使一个条上的边框比其他条上的边框更暗

EDIT: I've finally found time to give a brief example of this hack that allows at least 3 types of basic pattern in ggplot2. The code:

编辑:我终于抽出时间给出一个简单的例子,说明这个hack在ggplot2中至少允许3种类型的基本模式。代码:

Example.Data<- data.frame(matrix(vector(), 0, 3, dimnames=list(c(), c("Value", "Variable", "Fill"))), stringsAsFactors=F)

Example.Data[1, ] <- c(45, 'Horizontal Pattern','Horizontal Pattern' )
Example.Data[2, ] <- c(65, 'Vertical Pattern','Vertical Pattern' )
Example.Data[3, ] <- c(89, 'Mesh Pattern','Mesh Pattern' )


HighlightDataVert<-Example.Data[2, ]
HighlightHorizontal<-Example.Data[1, ]
HighlightMesh<-Example.Data[3, ]
HighlightHorizontal$Value<-as.numeric(HighlightHorizontal$Value)
Example.Data$Value<-as.numeric(Example.Data$Value)

HighlightDataVert$Value<-as.numeric(HighlightDataVert$Value)
HighlightMesh$Value<-as.numeric(HighlightMesh$Value)
HighlightHorizontal$Value<-HighlightHorizontal$Value-5
HighlightHorizontal2<-HighlightHorizontal
HighlightHorizontal2$Value<-HighlightHorizontal$Value-5
HighlightHorizontal3<-HighlightHorizontal2
HighlightHorizontal3$Value<-HighlightHorizontal2$Value-5
HighlightHorizontal4<-HighlightHorizontal3
HighlightHorizontal4$Value<-HighlightHorizontal3$Value-5
HighlightHorizontal5<-HighlightHorizontal4
HighlightHorizontal5$Value<-HighlightHorizontal4$Value-5
HighlightHorizontal6<-HighlightHorizontal5
HighlightHorizontal6$Value<-HighlightHorizontal5$Value-5
HighlightHorizontal7<-HighlightHorizontal6
HighlightHorizontal7$Value<-HighlightHorizontal6$Value-5
HighlightHorizontal8<-HighlightHorizontal7
HighlightHorizontal8$Value<-HighlightHorizontal7$Value-5

HighlightMeshHoriz<-HighlightMesh
HighlightMeshHoriz$Value<-HighlightMeshHoriz$Value-5
HighlightMeshHoriz2<-HighlightMeshHoriz
HighlightMeshHoriz2$Value<-HighlightMeshHoriz2$Value-5
HighlightMeshHoriz3<-HighlightMeshHoriz2
HighlightMeshHoriz3$Value<-HighlightMeshHoriz3$Value-5
HighlightMeshHoriz4<-HighlightMeshHoriz3
HighlightMeshHoriz4$Value<-HighlightMeshHoriz4$Value-5
HighlightMeshHoriz5<-HighlightMeshHoriz4
HighlightMeshHoriz5$Value<-HighlightMeshHoriz5$Value-5
HighlightMeshHoriz6<-HighlightMeshHoriz5
HighlightMeshHoriz6$Value<-HighlightMeshHoriz6$Value-5
HighlightMeshHoriz7<-HighlightMeshHoriz6
HighlightMeshHoriz7$Value<-HighlightMeshHoriz7$Value-5
HighlightMeshHoriz8<-HighlightMeshHoriz7
HighlightMeshHoriz8$Value<-HighlightMeshHoriz8$Value-5
HighlightMeshHoriz9<-HighlightMeshHoriz8
HighlightMeshHoriz9$Value<-HighlightMeshHoriz9$Value-5
HighlightMeshHoriz10<-HighlightMeshHoriz9
HighlightMeshHoriz10$Value<-HighlightMeshHoriz10$Value-5
HighlightMeshHoriz11<-HighlightMeshHoriz10
HighlightMeshHoriz11$Value<-HighlightMeshHoriz11$Value-5
HighlightMeshHoriz12<-HighlightMeshHoriz11
HighlightMeshHoriz12$Value<-HighlightMeshHoriz12$Value-5
HighlightMeshHoriz13<-HighlightMeshHoriz12
HighlightMeshHoriz13$Value<-HighlightMeshHoriz13$Value-5
HighlightMeshHoriz14<-HighlightMeshHoriz13
HighlightMeshHoriz14$Value<-HighlightMeshHoriz14$Value-5
HighlightMeshHoriz15<-HighlightMeshHoriz14
HighlightMeshHoriz15$Value<-HighlightMeshHoriz15$Value-5
HighlightMeshHoriz16<-HighlightMeshHoriz15
HighlightMeshHoriz16$Value<-HighlightMeshHoriz16$Value-5
HighlightMeshHoriz17<-HighlightMeshHoriz16
HighlightMeshHoriz17$Value<-HighlightMeshHoriz17$Value-5

ggplot(Example.Data, aes(x=Variable, y=Value, fill=Fill)) + theme_bw() + #facet_wrap(~Product, nrow=1)+ #Ensure theme_bw are there to create borders
  theme(legend.position = "none")+
  scale_fill_grey(start=.4)+
  #scale_y_continuous(limits = c(0, 100), breaks = (seq(0,100,by = 10)))+
  geom_bar(position=position_dodge(.9), stat="identity", colour="black", legend = FALSE)+
  geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.80)+
geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.60)+  
  geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.40)+
  geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.20)+
  geom_bar(data=HighlightDataVert, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.0) +
  geom_bar(data=HighlightHorizontal, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightHorizontal2, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightHorizontal3, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightHorizontal4, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightHorizontal5, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightHorizontal6, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightHorizontal7, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightHorizontal8, position=position_dodge(.9), stat="identity", colour="black", size=.5)+
  geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.80)+
 geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.60)+
  geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.40)+
  geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.20)+
  geom_bar(data=HighlightMesh, position=position_dodge(.9), stat="identity", colour="black", size=.5, width=0.0)+
  geom_bar(data=HighlightMeshHoriz, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
geom_bar(data=HighlightMeshHoriz2, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz3, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz4, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz5, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz6, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz7, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz8, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz9, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz10, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz11, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz12, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz13, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz14, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz15, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz16, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")+
  geom_bar(data=HighlightMeshHoriz17, position=position_dodge(.9), stat="identity", colour="black", size=.5, fill = "transparent")

Produces this:

产生这个:

enter image description here

It isn't super pretty but it is the only solution I can think on.

它不是非常漂亮,但它是我能想到的唯一解决方案。

As can be seen I produce some very basic data. To get the vertical lines I simply create a data frame to contain the variable I wanted to add vertical lines to and redrew the graph borders multiple times reducing the width each time.

可以看出,我产生了一些非常基本的数据。为了获得垂直线,我只需创建一个数据框来包含我想要添加垂直线的变量,并多次重新绘制图形边框,每次都减小宽度。

A similar thing is done for the horizontal lines but a new data frame is needed for each redraw where I have subtracted a value (in my example '5') from the value associated with the variable of interest. Effectively lowering the height of the bar. This is clunky to achieve and there may be more streamlined approaches but this illustrates how it can be achieved.

对于水平线也做了类似的事情,但每次重绘需要一个新的数据帧,我从与感兴趣的变量相关的值中减去一个值(在我的例子中为'5')。有效降低杆的高度。这很难实现,可能会有更简化的方法,但这说明了如何实现。

The mesh pattern is a combination of both. Firstly draw the vertical lines and then add the horizontal lines setting fill as fill='transparent' to ensure the vertical lines are not drawn over.

网格图案是两者的组合。首先绘制垂直线,然后添加水平线设置填充为fill ='transparent',以确保不绘制垂直线。

Until there is a pattern update I hope some of you find this useful.

在有模式更新之前,我希望你们中的一些人觉得这很有用。

EDIT 2:

编辑2:

Additionally diagonal patterns may also be added. I added an extra variable to the data frame:

另外还可以添加对角线图案。我在数据框中添加了一个额外的变量:

Example.Data[4,] <- c(20, 'Diagonal Pattern','Diagonal Pattern' )

Then I created a new data frame to hold coordinates for the diagonal lines:

然后我创建了一个新的数据框来保存对角线的坐标:

Diag <- data.frame(
  x = c(1,1,1.45,1.45), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y = c(0,0,20,20),
  x2 = c(1.2,1.2,1.45,1.45), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y2 = c(0,0,11.5,11.5),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines.
  x3 = c(1.38,1.38,1.45,1.45), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y3 = c(0,0,3.5,3.5),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines.
  x4 = c(.8,.8,1.26,1.26), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y4 = c(0,0,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines.
  x5 = c(.6,.6,1.07,1.07), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y5 = c(0,0,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines.
  x6 = c(.555,.555,.88,.88), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y6 = c(6,6,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines.
  x7 = c(.555,.555,.72,.72), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y7 = c(13,13,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines.
  x8 = c(.8,.8,1.26,1.26), # 1st 2 values dictate starting point of line. 2nd 2 dictate width. Each whole = one background grid
  y8 = c(0,0,20,20),# inner 2 values dictate height of horizontal line. Outer: vertical edge lines.
  #Variable = "Diagonal Pattern",
  Fill = "Diagonal Pattern"
  )

From there I added geom_paths to the ggplot above with each one calling different coordinates and drawing the lines over the desired bar:

从那里我将geom_paths添加到上面的ggplot中,每个调用不同的坐标并在所需的条上绘制线条:

+geom_path(data=Diag, aes(x=x, y=y),colour = "black")+  # calls co-or for sig. line & draws
  geom_path(data=Diag, aes(x=x2, y=y2),colour = "black")+  # calls co-or for sig. line & draws
  geom_path(data=Diag, aes(x=x3, y=y3),colour = "black")+
  geom_path(data=Diag, aes(x=x4, y=y4),colour = "black")+
  geom_path(data=Diag, aes(x=x5, y=y5),colour = "black")+
  geom_path(data=Diag, aes(x=x6, y=y6),colour = "black")+
  geom_path(data=Diag, aes(x=x7, y=y7),colour = "black")

This results in the following:

这导致以下结果:

enter image description here

It is a bit sloppy as I didn't invest too much time in getting the lines perfectly angled and spaced apart but this should serve as a proof of concept.

这有点草率,因为我没有投入太多时间让线条完美地成角度和间隔开,但这应该作为概念的证明。

Obviously the lines can lean the opposite direction and there is also room for diagonal meshing much like the horizontal and vertical meshing.

显然,线条可以向相反方向倾斜,并且还存在对角网格划分的空间,就像水平和垂直网格一样。

I think that's about all I can offer on the pattern front. Hope someone can find a use for it.

我认为这就是我在模式方面可以提供的所有内容。希望有人可以找到它的用途。

EDIT 3: Famous last words. I have come up with another pattern option. This time using geom_jitter.

编辑3:着名的遗言。我想出了另一个模式选项。这次使用geom_jitter。

Again I added another Variable to the data frame:

我再次向数据框添加了另一个变量:

Example.Data[5,] <- c(100, 'Bubble Pattern','Bubble Pattern' )

And I ordered how I wanted each pattern presented:

我订购了我希望每种模式呈现的方式:

Example.Data$Variable = Relevel(Example.Data$Variable, ref = c("Diagonal Pattern", "Bubble Pattern","Horizontal Pattern","Mesh Pattern","Vertical Pattern"))

Next I created a column to contain the number associated with the intended target bar on the x-axis:

接下来,我创建了一个列,用于包含与x轴上预期目标栏关联的数字:

Example.Data$Bubbles <- 2

Followed by columns to contain the positions on the y-axis of the 'bubbles':

后跟列包含“气泡”y轴上的位置:

Example.Data$Points <- c(5, 10, 15, 20, 25)
Example.Data$Points2 <- c(30, 35, 40, 45, 50)
Example.Data$Points3 <- c(55, 60, 65, 70, 75)
Example.Data$Points4 <- c(80, 85, 90, 95, 7)
Example.Data$Points5 <- c(14, 21, 28, 35, 42)
Example.Data$Points6 <- c(49, 56, 63, 71, 78)
Example.Data$Points7 <- c(84, 91, 98, 6, 12)

Finally I added geom_jitters to the ggplot above using the new columns for positioning and re-using 'Points' to vary the size of the 'bubbles':

最后,我将geom_jitters添加到上面的ggplot中,使用新列进行定位并重新使用'Points'来改变'bubbles'的大小:

+geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points3, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points4, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points2, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points5, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points6, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)+
  geom_jitter(data=Example.Data,aes(x=Bubbles, y=Points7, size=Points), alpha=.5)

Each time the plot is run the jitter positions the 'bubbles' differently but here is one of the nicer outputs I had:

每次运行绘图时,抖动都会以不同的方式定位“气泡”,但这是我输出的更好的输出之一:

enter image description here

Sometimes the 'bubbles' will jitter outside borders. If this happens rerun or simply export in larger dimensions. More bubbles can be plotted on each increment on the y-axis which will fill more of the blank space if you so desire.

有时候“气泡”会在国界外抖动。如果发生这种情况,请重新运行或直接以较大尺寸导出。如果您愿意,可以在y轴上的每个增量上绘制更多气泡,这将填充更多的空白区域。

That makes up to 7 patterns (if you include opposite leaning diagonal lines and diagonal mesh of both) that can be hacked in ggplot.

这可以构成7种模式(如果你包括相反的倾斜对角线和两者的对角网格),可以在ggplot中被黑客攻击。

Please feel free to suggest more if anyone can think on some.

如果有人可以考虑一些,请随时提出更多建议。

EDIT 4: I've been working on a wrapper function to automate hatching/patterns in ggplot2. I'll post a link once I've expanded the function to allow patterns in facet_grid plots etc. Here's an output with the function input for a simple plot of bars as an example:

编辑4:我一直在研究一个包装函数来自动化ggplot2中的阴影/模式。一旦我扩展了函数以允许facet_grid图中的模式等,我将发布一个链接。这里是一个带有函数输入的输出,用于简单的条形图作为示例:

enter image description here

I'll add one last edit once I have the function ready to share.

一旦我准备好分享功能,我将添加最后一个编辑。

EDIT 5: Here's a link to the function EggHatch that I wrote to make the process of adding patterns to geom_bar plots a little easier.

编辑5:这里是我编写的函数EggHatch的链接,使得向geom_bar图表添加模式的过程更容易一些。


推荐阅读
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文介绍了PE文件结构中的导出表的解析方法,包括获取区段头表、遍历查找所在的区段等步骤。通过该方法可以准确地解析PE文件中的导出表信息。 ... [详细]
  • This article discusses the efficiency of using char str[] and char *str and whether there is any reason to prefer one over the other. It explains the difference between the two and provides an example to illustrate their usage. ... [详细]
  • 本博文基于《Amalgamationofproteinsequence,structureandtextualinformationforimprovingprote ... [详细]
  • c语言\n不换行,c语言printf不换行
    本文目录一览:1、C语言不换行输入2、c语言的 ... [详细]
  • 本文介绍了一种划分和计数油田地块的方法。根据给定的条件,通过遍历和DFS算法,将符合条件的地块标记为不符合条件的地块,并进行计数。同时,还介绍了如何判断点是否在给定范围内的方法。 ... [详细]
  • 本文介绍了为什么要使用多进程处理TCP服务端,多进程的好处包括可靠性高和处理大量数据时速度快。然而,多进程不能共享进程空间,因此有一些变量不能共享。文章还提供了使用多进程实现TCP服务端的代码,并对代码进行了详细注释。 ... [详细]
  • 本文介绍了解决二叉树层序创建问题的方法。通过使用队列结构体和二叉树结构体,实现了入队和出队操作,并提供了判断队列是否为空的函数。详细介绍了解决该问题的步骤和流程。 ... [详细]
  • 本文介绍了C函数ispunct()的用法及示例代码。ispunct()函数用于检查传递的字符是否是标点符号,如果是标点符号则返回非零值,否则返回零。示例代码演示了如何使用ispunct()函数来判断字符是否为标点符号。 ... [详细]
  • 动态规划算法的基本步骤及最长递增子序列问题详解
    本文详细介绍了动态规划算法的基本步骤,包括划分阶段、选择状态、决策和状态转移方程,并以最长递增子序列问题为例进行了详细解析。动态规划算法的有效性依赖于问题本身所具有的最优子结构性质和子问题重叠性质。通过将子问题的解保存在一个表中,在以后尽可能多地利用这些子问题的解,从而提高算法的效率。 ... [详细]
  • Spring学习(4):Spring管理对象之间的关联关系
    本文是关于Spring学习的第四篇文章,讲述了Spring框架中管理对象之间的关联关系。文章介绍了MessageService类和MessagePrinter类的实现,并解释了它们之间的关联关系。通过学习本文,读者可以了解Spring框架中对象之间的关联关系的概念和实现方式。 ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • 本文介绍了在wepy中运用小顺序页面受权的计划,包含了用户点击作废后的从新受权计划。 ... [详细]
  • node.jsrequire和ES6导入导出的区别原 ... [详细]
  • [转载]从零开始学习OpenGL ES之四 – 光效
    继续我们的iPhoneOpenGLES之旅,我们将讨论光效。目前,我们没有加入任何光效。幸运的是,OpenGL在没有设置光效的情况下仍然可 ... [详细]
author-avatar
手机用户2502887831
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有