我的情节代码如下
Widget build(BuildContext context) {
return Container(
child: Scaffold(
backgroundColor: AppTheme.getTheme().backgroundColor,
body:Column(
children: <Widget>[
SizedBox(
height: MediaQuery.of(context).padding.top,
),
Expanded(
child: PageView(
controller: pageController,
pageSnapping: true,
onPageChanged: (index) {
currentShowIndex = index;
},
scrollDirection: Axis.horizontal,
children: <Widget>[
PagePopup(imageData: pageViewModelData[0]),
PagePopup(imageData: pageViewModelData[1]),
PagePopup(imageData: pageViewModelData[2]),
],
),
),
PageIndicator(
layout: PageIndicatorLayout.WARM,
size: 10.0,
controller: pageController,
space: 5.0,
count: 3,
color: AppTheme.getTheme().dividerColor,
activeColor: AppTheme.getTheme().primaryColor,
),
Padding(
padding: const EdgeInsets.only(left: 48, right: 48, bottom: 8, top: 32),
child: Container(
height: 48,
decoration: BoxDecoration(
color: AppTheme.getTheme().primaryColor,
borderRadius: BorderRadius.all(Radius.circular(24.0)),
boxShadow: <BoxShadow>[
BoxShadow(
color: AppTheme.getTheme().dividerColor,
blurRadius: 8,
offset: Offset(4, 4),
),
],
),
child: Material(
color: Colors.transparent,
child: InkWell(
borderRadius: BorderRadius.all(Radius.circular(24.0)),
highlightColor: Colors.transparent,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => LoginScreen()),
);
},
df1,df2和df3具有相同的以下结构
ggplot(NULL, aes(V2, V1)) +
geom_line(data = df1, colour = "blue") +
geom_line(data = df2, colour = "green") +
geom_line(data = df3, colour = "purple") +
theme(
legend.position = "bottom") +
输出未显示图例,但我需要区分情节上的线条。
答案 0 :(得分:3)
如果将数据放入一个数据框,然后使用一个geom_line
而不是多个library(ggplot2)
dplyr::bind_rows(df1 = df1, df2 = df2, df3 = df3, .id = "id") %>%
ggplot() + aes(V2, V1, color = id) +
geom_line() +
theme(legend.position = "bottom")
绘制数据,则可能会有所帮助。
df1 <- structure(list(V2 = 1:10, V1 = c(1.4, 1.5, 1.9, 4.5, 6.7, 7.8,
8.1, 8.2, 8.3, 8.9)), class = "data.frame", row.names = c(NA, -10L))
df2 <- structure(list(V2 = 1:10, V1 = c(1.43390152077191, 2.30610947613604,
2.23775280718692, 5.41628585802391, 7.05710641788319, 8.77536501311697,
8.48437852263451, 8.68867353517562, 8.7907762312796, 8.91225462416187
)), row.names = c(NA, -10L), class = "data.frame")
df3 <- structure(list(V2 = 1:10, V1 = c(2.04147320063785, 2.01257497165352,
2.22035211822949, 5.08143315766938, 7.31734440829605, 8.23827453767881,
8.27036898061633, 8.91508049662225, 9.04778654868715, 9.74391470812261
)), row.names = c(NA, -10L), class = "data.frame")
数据
ctx,cancel:=context.WithCancel(context.Background())
go func(ctx context.Context) {
for {
select {
case <-ctx.Done():
return
default
}
// Do stuff
}
}(ctx)
...
// Tell that goroutine to stop
cancel()