我想绘制一条线宽可变的曲线。如果我想使用点而不是线,通常会执行以下操作:
public static void WriteWorkBookToResponse(this IWorkbook book, HttpContext httpContext, string fileName)
{
var response = httpContext.Response;
using (var exportData = new MemoryStream())
{
response.Clear();
book.Write(exportData);
response.ContentType = "application/vnd.ms-excel";
response.Headers.Add("Content-Disposition", $"attachment;filename={fileName}.xls");
response.Body.Write(exportData.GetBuffer());
}
}
其中 curve.dat 充满:
public static async void WriteToResponse2(this IWorkbook book, HttpContext httpContext, string templateName)
{
var response = httpContext.Response;
using (var exportData = new MemoryStream())
{
book.Write(exportData);
// response.ContentLength = exportData.GetBuffer().Length;
response.ContentType = "application/vnd.ms-excel";
SetContentDispositionHeader(httpContext, templateName);
await StreamCopyOperation.CopyToAsync(exportData, response.Body, count: null, bufferSize: 64 * 1024, cancel: httpContext.RequestAborted);
}
}
private static void SetContentDispositionHeader(HttpContext httpContext, string fileName)
{
if (!string.IsNullOrEmpty(fileName))
{
var contentDisposition = new Microsoft.Net.Http.Headers.ContentDispositionHeaderValue("attachment");
contentDisposition.SetHttpFileName(fileName);
httpContext.Response.Headers[HeaderNames.ContentDisposition] = contentDisposition.ToString();
}
}
,依此类推。现在,如果我尝试对线宽 进行类似操作:
gnuplot> plot 'curve.dat' u ($1):($2):($1) ps var
我收到错误消息:
0 0
1 1
2 4
3 9
4 16
5 25
或者这是gnuplot无法完成的吗?
答案 0 :(得分:1)
这解决了加文答案的问题:他的方法会创建特定的线高(而不是线宽)。我发现了另一种方式,which works with widths。
我的解决方案中的缺陷:一个人需要事先知道“坐标空间宽高比”,并且在连接处会出现工件。