Untitled conversation
Jump to turn (7)
- User
{ "ASCCDCV": { "json": { "zlib": 5.426, "gzip": 5.579, "bz2": 23.072, "lz4": 0.482, "zstd": 2.402 }, "protobuf": { "zlib": 3.359, "gzip": 3.426, "bz2": 16.408, "lz4": 0.357, "zstd": 0.769 } }, "ARGAZAL": { "json": { "zlib": 1.542, "gzip": 1.457, "bz2": 6.131, "lz4": 0.158, "zstd": 0.702 }, "protobuf": { "zlib": 0.745, "gzip": 0.827, "bz2": 3.803, "lz4": 0.061, "zstd": 0.277 } }, "ARMAZAL": { "json": { "zlib": 0.785, "gzip": 0.719, "bz2": 3.442, "lz4": 0.075, "zstd": 0.306 }, "protobuf": { "zlib": 0.381, "gzip": 0.395, "bz2": 1.874, "lz4": 0.031, "zstd": 0.148 } }, "BWQAS": { "json": { "zlib": 0.868, "gzip": 0.903, "bz2": 3.903, "lz4": 0.055, "zstd": 0.342 }, "protobuf": { "zlib": 0.633, "gzip": 0.624, "bz2": 2.543, "lz4": 0.048, "zstd": 0.334 } }, "BWSAS": { "json": { "zlib": 1.942, "gzip": 1.943, "bz2": 8.609, "lz4": 0.156, "zstd": 0.709 }, "protobuf": { "zlib": 1.226, "gzip": 1.299, "bz2": 5.226, "lz4": 0.075, "zstd": 0.575 } }, "IOTNL": { "json": { "zlib": 10.738, "gzip": 11.230, "bz2": 46.428, "lz4": 1.000, "zstd": 5.061 }, "protobuf": { "zlib": 7.616, "gzip": 7.229, "bz2": 33.512, "lz4": 0.610, "zstd": 2.646 } }, "IOTTEMP": { "json": { "zlib": 1.893, "gzip": 1.996, "bz2": 7.610, "lz4": 0.145, "zstd": 0.783 }, "protobuf": { "zlib": 1.387, "gzip": 1.609, "bz2": 6.869, "lz4": 0.140, "zstd": 0.440 } }, "IOT1": { "json": { "zlib": 1.775, "gzip": 1.912, "bz2": 8.118, "lz4": 0.157, "zstd": 0.866 }, "protobuf": { "zlib": 1.023, "gzip": 1.245, "bz2": 5.980, "lz4": 0.144, "zstd": 0.240 } }, "IOT2": { "json": { "zlib": 4.279, "gzip": 4.550, "bz2": 18.493, "lz4": 0.439, "zstd": 2.099 }, "protobuf": { "zlib": 2.741, "gzip": 2.915, "bz2": 11.886, "lz4": 0.252, "zstd": 1.214 } }, "IOT3": { "json": { "zlib": 3.732, "gzip": 4.173, "bz2": 17.577, "lz4": 0.329, "zstd": 1.946 }, "protobuf": { "zlib": 2.238, "gzip": 2.624, "bz2": 12.388, "lz4": 0.270, "zstd": 0.492 } }, "IOT4": { "json": { "zlib": 2.154, "gzip": 2.311, "bz2": 9.599, "lz4": 0.155, "zstd": 0.829 }, "protobuf": { "zlib": 1.380, "gzip": 1.452, "bz2": 6.539, "lz4": 0.147, "zstd": 0.438 } }, "IOT6": { "json": { "zlib": 2.170, "gzip": 2.137, "bz2": 9.500, "lz4": 0.171, "zstd": 0.859 }, "protobuf": { "zlib": 1.391, "gzip": 1.424, "bz2": 6.703, "lz4": 0.153, "zstd": 0.476 } }, "IOT7": { "json": { "zlib": 7.116, "gzip": 7.173, "bz2": 30.495, "lz4": 0.790, "zstd": 3.001 }, "protobuf": { "zlib": 4.467, "gzip": 5.084, "bz2": 19.546, "lz4": 0.392, "zstd": 2.304 } }, "IOT8": { "json": { "zlib": 1.445, "gzip": 1.426, "bz2": 7.131, "lz4": 0.142, "zstd": 0.750 }, "protobuf": { "zlib": 0.986, "gzip": 1.099, "bz2": 4.416, "lz4": 0.079, "zstd": 0.215 } }, "IOT9": { "json": { "zlib": 3.081, "gzip": 3.208, "bz2": 14.090, "lz4": 0.255, "zstd": 1.324 }, "protobuf": { "zlib": 2.230, "gzip": 2.125, "bz2": 9.687, "lz4": 0.185, "zstd": 0.465 } }, "IOT10": { "json": { "zlib": 0.016, "gzip": 0.011, "bz2": 0.049, "lz4": 0.001, "zstd": 0.007 }, "protobuf": { "zlib": 0.009, "gzip": 0.009, "bz2": 0.034, "lz4": 0.001, "zstd": 0.002 } }, "IOT11": { "json": { "zlib": 0.061, "gzip": 0.062, "bz2": 0.245, "lz4": 0.004, "zstd": 0.034 }, "protobuf": { "zlib": 0.059, "gzip": 0.057, "bz2": 0.188, "lz4": 0.005, "zstd": 0.010 } }, "IOT12": { "json": { "zlib": 0.073, "gzip": 0.068, "bz2": 0.297, "lz4": 0.008, "zstd": 0.027 }, "protobuf": { "zlib": 0.039, "gzip": 0.043, "bz2": 0.204, "lz4": 0.004, "zstd": 0.010 } }, "TAZAW": { "json": { "zlib": 1.460, "gzip": 1.329, "bz2": 5.739, "lz4": 0.126, "zstd": 0.545 }, "protobuf": { "zlib": 0.687, "gzip": 0.777, "bz2": 3.428, "lz4": 0.058, "zstd": 0.236 } } } i need plot for this plt
Sure, I can help you with that. What type of plot are you looking for? A bar plot, line plot, scatter plot, etc?
line plot python
Here is an example Python code snippet that you can use to create a line plot for the given data using matplotlib:
import matplotlib.pyplot as plt
data = {
"ASCCDCV": {
"json": {
"zlib": 5.426,
"gzip": 5.579,
"bz2": 23.072,
"lz4": 0.482,
"zstd": 2.402
},
"protobuf": {
"zlib": 3.359,
"gzip": 3.426,
"bz2": 16.408,
"lz4": 0.357,
"zstd": 0.769
}
},
# Add the rest of the data here
}
protocols = ["json", "protobuf"]
compression_algorithms = ["zlib", "gzip", "bz2", "lz4", "zstd"]
for protocol in protocols:
for algorithm in compression_algorithms:
values = [data[key][protocol][algorithm] for key in data]
plt.plot(list(data.keys()), values, label=f"{protocol} - {algorithm}")
plt.xlabel('Data Sets')
plt.ylabel('Compression Ratio')
plt.title('Compression Ratio by Data Set')
plt.xticks(rotation=45)
plt.legend()
plt.show()
You will need to add the rest of the data to the data dictionary in order for this code to work. Just copy the existing structure and fill in the new data points.
This code snippet will plot the compression ratios for each data set, protocol, and compression algorithm in a line plot. You can run this code in a Python environment (like Jupyter Notebook or any IDE) that has matplotlib installed.
make it bar plot
Here is the modified code snippet to create a bar plot for the given data using matplotlib:
import matplotlib.pyplot as plt
import numpy as np
data = {
"ASCCDCV": {
"json": {
"zlib": 5.426,
"gzip": 5.579,
"bz2": 23.072,
"lz4": 0.482,
"zstd": 2.402
},
"protobuf": {
"zlib": 3.359,
"gzip": 3.426,
"bz2": 16.408,
"lz4": 0.357,
"zstd": 0.769
}
},
# Add the rest of the data here
}
protocols = ["json", "protobuf"]
compression_algorithms = ["zlib", "gzip", "bz2", "lz4", "zstd"]
data_sets = list(data.keys())
bar_width = 0.35
index = np.arange(len(data_sets))
for i, algorithm in enumerate(compression_algorithms):
fig, ax = plt.subplots()
for j, protocol in enumerate(protocols):
values = [data[key][protocol][algorithm] for key in data]
ax.bar(index + j*bar_width, values, bar_width, label=f"{protocol}", align='center')
ax.set_xlabel('Data Sets')
ax.set_ylabel('Compression Ratio')
ax.set_title(f'Compression Ratio by Compression Algorithm: {algorithm}')
ax.set_xticks(index + bar_width / 2)
ax.set_xticklabels(data_sets)
ax.legend()
plt.xticks(rotation=45)
plt.tight_layout()
plt.show()
You can run this code snippet in a Python environment (like Jupyter Notebook or any IDE) that has matplotlib installed. This code will create separate bar plots for each compression algorithm, showing the compression ratios for each data set and protocol.
make it like this import matplotlib.pyplot as plt
datasets = list(avg_sizes.keys()) algorithms = list(avg_sizes[datasets[0]].keys()) average_sizes = [[avg_sizes[dataset][algorithm] for algorithm in algorithms] for dataset in datasets]
plt.figure(figsize=(10, 6)) bar_width = 0.07 index = range(len(datasets))
for i, algorithm in enumerate(algorithms): plt.bar([x + i * bar_width for x in index], [avg_sizes[i] for avg_sizes in average_sizes], bar_width, label=algorithm)
plt.xlabel('Datasets') plt.ylabel('Average Size of Messages') plt.title('Average Size of Serialized and Compressed Messages by Dataset, Serializer and Compression Algorithm') plt.xticks([x + (len(algorithms) - 1) * bar_width / 2 for x in index], datasets, fontsize=6) plt.legend(ncol=2) plt.tight_layout()
plt.show()
Here is the modified code snippet based on the format you have provided:
import matplotlib.pyplot as plt
data = {
"ASCCDCV": {
"json": {
"zlib": 5.426,
"gzip": 5.579,
"bz2": 23.072,
"lz4": 0.482,
"zstd": 2.402
},
"protobuf": {
"zlib": 3.359,
"gzip": 3.426,
"bz2": 16.408,
"lz4": 0.357,
"zstd": 0.769
}
},
# Add the rest of the data here
}
datasets = list(data.keys())
algorithms = list(data[datasets[0]]['json'].keys())
average_sizes = [[data[dataset]['json'][algorithm] for algorithm in algorithms] for dataset in datasets]
plt.figure(figsize=(10, 6))
bar_width = 0.07
index = range(len(datasets))
for i, algorithm in enumerate(algorithms):
plt.bar([x + i * bar_width for x in index], [avg_sizes[i] for avg_sizes in average_sizes], bar_width, label=algorithm)
plt.xlabel('Datasets')
plt.ylabel('Average Size of Messages')
plt.title('Average Size of Serialized and Compressed Messages by Dataset, Serializer and Compression Algorithm')
plt.xticks([x + (len(algorithms) - 1) * bar_width / 2 for x in index], datasets, fontsize=6)
plt.legend(ncol=2)
plt.tight_layout()
plt.show()
You can run this code snippet in a Python environment (like Jupyter Notebook or any IDE) that has matplotlib installed. This code will create a bar plot with the average size of messages for each dataset, serializer, and compression algorithm.
make logarithmic axis y
To create a bar plot with a logarithmic y-axis, you can use the plt.yscale('log') function from matplotlib. Here is the modified code snippet with a logarithmic y-axis:
import matplotlib.pyplot as plt
data = {
"ASCCDCV": {
"json": {
"zlib": 5.426,
"gzip": 5.579,
"bz2": 23.072,
"lz4": 0.482,
"zstd": 2.402
},
"protobuf": {
"zlib": 3.359,
"gzip": 3.426,
"bz2": 16.408,
"lz4": 0.357,
"zstd": 0.769
}
},
# Add the rest of the data here
}
datasets = list(data.keys())
algorithms = list(data[datasets[0]]['json'].keys())
average_sizes = [[data[dataset]['json'][algorithm] for algorithm in algorithms] for dataset in datasets]
plt.figure(figsize=(10, 6))
bar_width = 0.07
index = range(len(datasets))
for i, algorithm in enumerate(algorithms):
plt.bar([x + i * bar_width for x in index], [avg_sizes[i] for avg_sizes in average_sizes], bar_width, label=algorithm)
plt.xlabel('Datasets')
plt.ylabel('Average Size of Messages')
plt.yscale('log')
plt.title('Average Size of Serialized and Compressed Messages by Dataset, Serializer and Compression Algorithm')
plt.xticks([x + (len(algorithms) - 1) * bar_width / 2 for x in index], datasets, fontsize=6)
plt.legend(ncol=2)
plt.tight_layout()
plt.show()
This code snippet will plot the bar chart with a logarithmic y-axis. You can run this code in a Python environment with matplotlib installed to visualize the bar chart with a logarithmic y-axis.
also for proto
Here is the modified code snippet with a logarithmic y-axis for the protobuf data:
import matplotlib.pyplot as plt
data = {
"ASCCDCV": {
"json": {
"zlib": 5.426,
"gzip": 5.579,
"bz2": 23.072,
"lz4": 0.482,
"zstd": 2.402
},
"protobuf": {
"zlib": 3.359,
"gzip": 3.426,
"bz2": 16.408,
"lz4": 0.357,
"zstd": 0.769
}
},
# Add the rest of the data here
}
datasets = list(data.keys())
algorithms = list(data[datasets[0]]['protobuf'].keys())
average_sizes = [[data[dataset]['protobuf'][algorithm] for algorithm in algorithms] for dataset in datasets]
plt.figure(figsize=(10, 6))
bar_width = 0.07
index = range(len(datasets))
for i, algorithm in enumerate(algorithms):
plt.bar([x + i * bar_width for x in index], [avg_sizes[i] for avg_sizes in average_sizes], bar_width, label=algorithm)
plt.xlabel('Datasets')
plt.ylabel('Average Size of Messages')
plt.yscale('log')
plt.title('Average Size of Serialized and Compressed Messages by Dataset, Serializer and Compression Algorithm (Protobuf)')
plt.xticks([x + (len(algorithms) - 1) * bar_width / 2 for x in index], datasets, fontsize=6)
plt.legend(ncol=2)
plt.tight_layout()
plt.show()
You can run this code snippet in a Python environment with matplotlib installed to visualize the bar chart with a logarithmic y-axis for the protobuf data.
on the same plot json and protobuf
You can combine the data for both JSON and Protobuf and create a single bar plot with a logarithmic y-axis for both. Here is the modified code snippet that combines and plots the data for both JSON and Protobuf on the same plot:
import matplotlib.pyplot as plt
data = {
"ASCCDCV": {
"json": {
"zlib": 5.426,
"gzip": 5.579,
"bz2": 23.072,
"lz4": 0.482,
"zstd": 2.402
},
"protobuf": {
"zlib": 3.359,
"gzip": 3.426,
"bz2": 16.408,
"lz4": 0.357,
"zstd": 0.769
}
},
# Add the rest of the data here
}
datasets = list(data.keys())
algorithms = list(data[datasets[0]]['json'].keys())
average_sizes_json = [[data[dataset]['json'][algorithm] for algorithm in algorithms] for dataset in datasets]
average_sizes_protobuf = [[data[dataset]['protobuf'][algorithm] for algorithm in algorithms] for dataset in datasets]
plt.figure(figsize=(10, 6))
bar_width = 0.07
index = range(len(datasets))
for i, algorithm in enumerate(algorithms):
plt.bar([x + i * bar_width for x in index], [avg_sizes[i] for avg_sizes in average_sizes_json], bar_width, label=f"JSON - {algorithm}")
plt.bar([x + i * bar_width for x in index], [avg_sizes[i] for avg_sizes in average_sizes_protobuf], bar_width, label=f"Protobuf - {algorithm}")
plt.xlabel('Datasets')
plt.ylabel('Average Size of Messages')
plt.yscale('log')
plt.title('Average Size of Serialized and Compressed Messages by Dataset, Serializer and Compression Algorithm')
plt.xticks([x + (len(algorithms) - 1) * bar_width / 2 for x in index], datasets, fontsize=6)
plt.legend(ncol=2)
plt.tight_layout()
plt.show()
This code snippet will plot the bar chart with a logarithmic y-axis for both JSON and Protobuf data on the same plot. You can run this code in a Python environment with matplotlib installed to visualize the combined bar chart with a logarithmic y-axis for JSON and Protobuf data.
Not yet included in a published release.