我试图用散点图绘制一个大型数据集.我想用matplotlib用单像素标记来绘制它.它似乎已经解决了.
https://github.com/matplotlib/matplotlib/pull/695
但我找不到如何获得单个像素标记.
我的简化数据集(data.csv)
Length,Time
78154393,139.324091
84016477,229.159305
84626159,219.727537
102021548,225.222662
106399706,221.022827
107945741,206.760239
109741689,200.153263
126270147,220.102802
207813132,181.67058
610704756,50.59529
623110004,50.533158
653383018,52.993885
659376270,53.536834
680682368,55.97628
717978082,59.043843
Run Code Online (Sandbox Code Playgroud)
我的代码如下.
import pandas as pd
import os
import numpy
import matplotlib.pyplot as plt
inputfile='data.csv'
iplevel = pd.read_csv(inputfile)
base = os.path.splitext(inputfile)[0]
fig = plt.figure()
plt.yscale('log')
#plt.xscale('log')
plt.title(' My plot: '+base)
plt.xlabel('x')
plt.ylabel('y')
plt.scatter(iplevel['Time'], iplevel['Length'],color='black',marker=',',lw=0,s=1)
fig.tight_layout()
fig.savefig(base+'_plot.png', dpi=fig.dpi)
Run Code Online (Sandbox Code Playgroud)
您可以在下面看到这些点不是单个像素.
任何帮助表示赞赏
如何使用 shell 脚本将零填充为二进制数。
二进制.txt
1010011100010001010111001101111
0
10110000000101000000000000001
10100000011
1000000100
1111111111111111
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
Run Code Online (Sandbox Code Playgroud)
当我执行以下操作时
printf "%032s\n" $(<binary.txt)
Run Code Online (Sandbox Code Playgroud)
我得到一个空白。
1010011100010001010111001101111
0
10110000000101000000000000001
10100000011
1000000100
1111111111111111
11111111111111110000000000000000
11111111111111110000000000000000
11111111111111110000000000000000
Run Code Online (Sandbox Code Playgroud)
但我需要附加零。任何意见都会受到赞赏。谢谢,
更新:
binary.txt 是我的输入文件,具有以下内容。
1010011100010001010111001101111
0
10110000000101000000000000001
10100000011
1000000100
1111111111111111
11111111111111110000000000000000
11111111111111110000000000000000
Run Code Online (Sandbox Code Playgroud)
在命令行中运行以下命令时,它工作正常。
printf "%032s\n" $(<binary.txt) | tr ' ' '0' >> t1.mif
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用下面的脚本执行相同操作时,它给了我错误的值。有什么建议。
#!/bin/bash
FILE=binary.txt
while read line;do
printf "%032s\n" $line | tr ' ' '0' >> t1.mif
done < $FILE
Run Code Online (Sandbox Code Playgroud)
谢谢
我一直在尝试开发一个简单的事件驱动模拟器,并从这里开始
http://stdcxx.apache.org/doc/stdlibug/11-3.html
当我正在玩这个例子进行一些修改时,我遇到了一个条件,当两个事件(到达,离开)同时发生时(比如在时间单元5),然后模拟器只是弹出顶部的任何东西事件队列可以从下面的代码片段中看到.
void simulation::run () {
while (! eventQueue.empty ()) {
event * nextEvent = eventQueue.top ();
eventQueue.pop ();
time = nextEvent->time;
nextEvent->processEvent ();
delete nextEvent;
}
}
Run Code Online (Sandbox Code Playgroud)
如果两个事件同时发生,我如何强制执行始终在出发事件之前弹出特定事件(首先到达事件)的条件.
任何帮助深表感谢.
我试图使用sleep命令延迟程序.但是当我打印结果时,我没有看到延迟.我错过了什么.
#include <iostream>
#include <stdlib.h>
#include <ctime>
#include <string.h>
#include <sys/time.h> // for time
#include <unistd.h> // for microsecond sleep
using namespace std;
const std::string currentDateTime()
{
time_t now = time(0);
struct tm tstruct;
char buf[80];
tstruct = *localtime(&now);
strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);
return buf;
}
int main(){
unsigned int microseconds = 10000000 ;
int min = 1;
int max = 10;
int randNum =0;
time_t t;
for(int i=0;i<5;i++)
{
randNum = rand()%(max-min + 1) + min;
std::cout << "At …Run Code Online (Sandbox Code Playgroud) 我有兴趣知道是否有一种简单的方法可以在每行的末尾添加分号.我试过但总是在下一行打印分号.
rom_data.txt
0123
1
253
3
Run Code Online (Sandbox Code Playgroud)
my_script.py
input_file = open("rom_data.txt", "r")
for line in input_file:
final= line+';'
print final
Run Code Online (Sandbox Code Playgroud)
预期产出
0123;
1;
253;
3;
Run Code Online (Sandbox Code Playgroud)
得到的输出
0123
;
1
;
253
;
3
;
Run Code Online (Sandbox Code Playgroud)
谁能告诉我哪里出错了?
如何从以下转储中提取仅带宽值
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 85.3 KByte (default)
------------------------------------------------------------
[ 4] local 192.168.1.1 port 5001 connected with 192.168.1.2 port 51725
[ ID] Interval Transfer Bandwidth
[ 4] 0.0-10.0 sec 10.7 GBytes 9.17 Gbits/sec
[ 5] local 192.168.1.1 port 5001 connected with 192.168.1.2 port 51726
[ 5] 0.0-10.0 sec 10.7 GBytes 9.17 Gbits/sec
[ 4] local 192.168.1.1 port 5001 connected with 192.168.1.2 port 51727
[ 4] 0.0-10.0 sec 10.6 GBytes 9.10 Gbits/sec
[ 5] local …Run Code Online (Sandbox Code Playgroud) python ×3
c++ ×2
awk ×1
bash ×1
binary ×1
event-driven ×1
matplotlib ×1
printf ×1
regex ×1
scatter-plot ×1
scripting ×1
sed ×1
shell ×1
sleep ×1
time ×1