论文代码画图(根据自己的论文要求画图)
以下为svg代码,根据自己论文画图,有部分删减
<svg height="400" width="850" xmlns="http://www.w3.org/2000/svg">
<style>
.small {
font: italic 30px sans-serif;
}
</style>
<text x="45" y="97" class="small">r<tspan dy="5" font-size="15">min</tspan></text>
<text x="195" y="97" class="small">r<tspan dy="5" font-size="15">1</tspan></text>
<text x="345" y="97" class="small">r<tspan dy="5" font-size="15">2</tspan></text>
<text x="495" y="97" class="small">r<tspan dy="5" font-size="15">3</tspan></text>
<text x="645" y="97" class="small">r<tspan dy="5" font-size="15">4</tspan></text>
<text x="795" y="97" class="small">r<tspan dy="5" font-size="15">max</tspan></text>
<text x="242" y="350" class="small">r<tspan dy="5" font-size="15">min</tspan></text>
<text x="340" y="350" class="small">r<tspan dy="5" font-size="15">1</tspan></text>
<text x="430" y="350" class="small">r<tspan dy="5" font-size="15">2</tspan></text>
<text x="525" y="350" class="small">r<tspan dy="5" font-size="15">3</tspan></text>
<text x="620" y="350" class="small">r<tspan dy="5" font-size="15">4</tspan></text>
<text x="710" y="350" class="small">r<tspan dy="5" font-size="15">max</tspan></text>
<line
x1="50"
y1="100"
x2="50"
y2="130"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<line
x1="50"
y1="115"
x2="800"
y2="115"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<line
x1="800"
y1="100"
x2="800"
y2="130"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<defs>
<marker
id="triangle"
markerUnits="strokeWidth"
markerWidth="5"
markerHeight="4"
refX="0"
refY="2"
orient="auto"
>
<path d="M 0 0 L 5 2 L 0 4 z" />
</marker>
</defs>
<path
d="M 50,135 L 235,305"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<defs>
<marker
id="triangle"
markerUnits="strokeWidth"
markerWidth="5"
markerHeight="4"
refX="0"
refY="2"
orient="auto"
>
<path d="M 0 0 L 5 2 L 0 4 z" />
</marker>
</defs>
<path
d="M 800,135 L 731,302"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<path
stroke-dasharray="10,5"
d="M200 135 330 285"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<path
stroke-dasharray="10,5"
d="M350 135 430 284"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<path
stroke-dasharray="10,5"
d="M500 135 528 282"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<path
stroke-dasharray="10,5"
d="M650 135 628 282"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<g fill="none" stroke="black" stroke-width="4">
<path stroke-dasharray="5,5" d="M200 100 200 130" />
<path stroke-dasharray="5,5" d="M500 100 500 130" />
<path stroke-dasharray="5,5" d="M650 100 650 130" />
<path stroke-dasharray="5,5" d="M344 300 344 330" />
<path stroke-dasharray="5,5" d="M626 300 626 330" />
</g>
<line
x1="250"
y1="300"
x2="250"
y2="330"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<line
x1="720"
y1="300"
x2="720"
y2="330"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
</svg>
转换为svg图片; 供给在浏览器可另存为图片形式
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
<script>
var svgCode = `<svg height="400" width="850" xmlns="http://www.w3.org/2000/svg">
<style>
.small {
font: italic 30px sans-serif;
}
</style>
<text x="45" y="97" class="small">r<tspan dy="5" font-size="15">min</tspan></text>
<text x="195" y="97" class="small">r<tspan dy="5" font-size="15">1</tspan></text>
<text x="345" y="97" class="small">r<tspan dy="5" font-size="15">2</tspan></text>
<text x="495" y="97" class="small">r<tspan dy="5" font-size="15">3</tspan></text>
<text x="645" y="97" class="small">r<tspan dy="5" font-size="15">4</tspan></text>
<text x="795" y="97" class="small">r<tspan dy="5" font-size="15">max</tspan></text>
<text x="242" y="350" class="small">r<tspan dy="5" font-size="15">min</tspan></text>
<text x="340" y="350" class="small">r<tspan dy="5" font-size="15">1</tspan></text>
<text x="430" y="350" class="small">r<tspan dy="5" font-size="15">2</tspan></text>
<text x="525" y="350" class="small">r<tspan dy="5" font-size="15">3</tspan></text>
<text x="620" y="350" class="small">r<tspan dy="5" font-size="15">4</tspan></text>
<text x="710" y="350" class="small">r<tspan dy="5" font-size="15">max</tspan></text>
<line
x1="50"
y1="100"
x2="50"
y2="130"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<line
x1="50"
y1="115"
x2="800"
y2="115"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<line
x1="800"
y1="100"
x2="800"
y2="130"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<defs>
<marker
id="triangle"
markerUnits="strokeWidth"
markerWidth="5"
markerHeight="4"
refX="0"
refY="2"
orient="auto"
>
<path d="M 0 0 L 5 2 L 0 4 z" />
</marker>
</defs>
<path
d="M 50,135 L 235,305"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<defs>
<marker
id="triangle"
markerUnits="strokeWidth"
markerWidth="5"
markerHeight="4"
refX="0"
refY="2"
orient="auto"
>
<path d="M 0 0 L 5 2 L 0 4 z" />
</marker>
</defs>
<path
d="M 800,135 L 731,302"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<path
stroke-dasharray="10,5"
d="M200 135 330 285"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<path
stroke-dasharray="10,5"
d="M350 135 430 284"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)"
/>
<path
stroke-dasharray="10,5"
d="M500 135 528 282"
stroke="black"
stroke-width="3"
fill="none"
style="marker-end: url(#triangle)
</g>
<line
x1="250"
y1="315"
x2="720"
y2="315"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
<line
x1="720"
y1="300"
x2="720"
y2="330"
style="stroke: rgb(0, 0, 0); stroke-width: 3"
/>
</svg>`;
var blob = new Blob([svgCode], { type: "image/svg+xml" });
var url = URL.createObjectURL(blob);
var img = new Image();
img.src = url;
document.body.appendChild(img);
</script>
</body>
</html>
套路
var svgCode = "<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><rect x='50' y='50' width='100' height='100' fill='red' /></svg>";
var blob = new Blob([svgCode], { type: 'image/svg+xml' });
var url = URL.createObjectURL(blob);
var img = new Image();
img.src = url;
document.body.appendChild(img);