我试图制作一个图表,Y轴上有3个点,x轴上有时间。数据如下:
<CustomItem title={item.title} small={true} />
代码如下:
const small = this.props.small;
<Text style={[styles.title]}> {title} </Text>
const styles = StyleSheet.create({
title:{
fontSize: small ? 10 : 20, // error here
fontWeight: 'bold'
}
on 0.00059642,0.00060012,0.00059642,0.00060012,1112.25854421,2017-10-11T19:45:00,0.66505583
0.00060011,0.00060012,0.00059642,0.00059922,3637.58805798,2017-10-11T19:50:00,2.17918273
0.00059922,0.00059999,0.00059922,0.00059922,395.62320194,2017-10-11T19:55:00,0.23722457
0.00059922,0.00059999,0.00058506,0.00059518,4551.22115392,2017-10-11T20:00:00,2.70701959
我收到了错误。
答案 0 :(得分:0)
它无法将timestamp
转换为定义轴上位置所需的数值。但是,你不需要这个,因为你只需要恒定的距离,正如我所理解的那样。
你可以做到
plt.xticks(np.arange(4), data["T"], rotation=30)
答案 1 :(得分:0)
让matplotlib处理x轴上的日期怎么样,
import java.io.{BufferedOutputStream, ByteArrayInputStream, ByteArrayOutputStream}
import java.util.zip.{ZipEntry, ZipOutputStream}
import akka.stream.scaladsl.{StreamConverters}
import org.apache.commons.io.FileUtils
import play.api.mvc.{Action, Controller}
class HomeController extends Controller {
def single() = Action {
Ok.sendFile(
content = new java.io.File("C:\\Users\\a.csv"),
fileName = _ => "a.csv"
)
}
def zip() = Action {
Ok.chunked(StreamConverters.fromInputStream(fileByteData)).withHeaders(
CONTENT_TYPE -> "application/zip",
CONTENT_DISPOSITION -> s"attachment; filename = test.zip"
)
}
def fileByteData(): ByteArrayInputStream = {
val fileList = List(
new java.io.File("C:\\Users\\a.csv"),
new java.io.File("C:\\Users\\b.csv")
)
val baos = new ByteArrayOutputStream()
val zos = new ZipOutputStream(new BufferedOutputStream(baos))
try {
fileList.map(file => {
zos.putNextEntry(new ZipEntry(file.toPath.getFileName.toString))
zos.write(FileUtils.readFileToByteArray(file))
zos.closeEntry()
})
} finally {
zos.close()
}
new ByteArrayInputStream(baos.toByteArray)
}
}