如何绘制季节性图?

时间:2019-06-26 04:04:05

标签: r ggplot2

我想建立一个图表来确定从1月到12月的流感病毒的季节性,并每年对其分组(2011-2018年),但是我的结果存在问题。

我想要与本出版物中出现的图形类似的图形:https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0193263

outcome<- factor(c(rep("positive", 60)))
month<- sample(1:12,60,replace=T)
year <- sample(2011:2018,60,replace=T)
data<- data.frame(outcome, month, year)
ggplot(data, aes(x=month, y= frequency(data$outcome),
                 group = year, fill = year)) + geom_col(position = "dodge")

2 个答案:

答案 0 :(得分:1)

 public async Task ProduceAsync<TEvent>(TEvent ipmEvent, string topicName)
    where TEvent : ISpecificRecord
    {
      using (var producerClient = kafkaProducerConnection.ProducerBuilder<Null, TEvent>())
      {
        await producerClient.ProduceAsync(topicName, new Message<Null, TEvent> { Value = ipmEvent }).ContinueWith(
            reportTask =>
            {
              if (reportTask.IsCompletedSuccessfully)
              {
                var deliveryReport = reportTask.Result;
                logger.LogInformation($"KafkaProducer.ProduceAsync: Delivered message to {deliveryReport.TopicPartitionOffset}");
              }
              else if (reportTask.IsFaulted && reportTask.Exception != null)
              {
                var exceptionMessages = string.Join(". ", reportTask.Exception.InnerExceptions.Select(e => e.Message));
                logger.LogError($"KafkaProducer.ProduceAsync failed - {exceptionMessages}");
                throw new Exception($"Error sending message, {reportTask.Exception}");
              }
              else
              {
                logger.LogError($"KafkaProducer.ProduceAsync failed");
                throw new Exception($"Error sending message {reportTask.Exception}");
              }
            });
      }
    }

enter image description here

答案 1 :(得分:0)

假设您的意思是论文中的第一张图,最简单的方法是Expanded( flex: 25, child:StreamBuilder<DocumentSnapshot>( stream: Firestore.instance .collection("Users") .document(widget.userEmail) .collection("Flight Data") .document("Courses") .collection(widget.courseAbbr) .document(_dateSelected).snapshots(), builder: (context, snapshot){ if (snapshot.hasError) { return new Text('${snapshot.error}'); } else if (!snapshot.hasData) { return Center(child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation<Color>(white),)); } else { switch (snapshot.connectionState) { case ConnectionState.waiting: return Center(child: CircularProgressIndicator(valueColor: AlwaysStoppedAnimation<Color>(white),)); default: var doc = snapshot.data; // can execute animation here to make select flight glow if (_dateSelected == null) { return (Center(child: SizedBox(),)); } return ListView( children: <Widget>[ Container( height: MediaQuery.of(context).size.height*2/3, decoration: BoxDecoration( color: blackTrans, borderRadius: BorderRadius.all(Radius.circular(5.0)), ), child: ListView.builder( padding: EdgeInsets.only(top: 0.0), scrollDirection: Axis.vertical, shrinkWrap: false, itemCount: _dateSelected == null ? 1 : doc["patterns"].length + 1, itemBuilder: (BuildContext context, int index) { if (index == 0) { return Column( children: <Widget>[ ListTile( selected: false, title: AutoSizeText( NA_FLIGHT_PAGE_PATTERN, maxLines: 1, style: TextStyle( color: white, ), textAlign: TextAlign.center, ), ), Divider(color: white,) ], ); } index -= 1; var patterns = doc["patterns"]; return buildPatternTile(patterns[index]); } ), ), ], ); } } }, ), ), facet_wrap

编辑-我也想补充一点,如果您正在尝试R不会阻止像facet_grid这样的注释。