Comments (9)
Hi @andresriancho ,
Thank you! I am happy that it is useful for you 😊 . Regarding the issue: it looks like you are not using the latest version. I ran into the same displaying issues and made some changes in v3.2 that should keep labels in their 8-9 characters. Please try updating and see if that fixes the issue?
BTW: It looks like you are plotting timestamps (vs ... something else ;) ). In v3.2 it should be possible to directly give the datetime
objects as X values.
from plotille.
Awesome! Upgrading fixed 50% of my problem: now I can read the values 👍
What about only displaying the integer part of the number in the X axis?
from plotille.
Right now, there are no plans to only show integer parts, or have an option for this... anyway, with the last update, you can supply formatters to a figure, that will render all labels (also the Y-axis), e.g.:
from plotille import *
import random
def _num_formatter(val, chars, delta, left=False):
align = '<' if left else ''
return '{:{}{}d}'.format(int(val), align, chars)
fig = Figure()
fig.width = 30
fig.height = 15
fig.register_label_formatter(float, _num_formatter)
fig.register_label_formatter(int, _num_formatter)
fig.plot(list(range(100)), [random.randint(0, 20) for _i in range(100)])
print(fig.show())
from plotille.
Lovely, you rock!
from plotille.
😊 Thx.
from plotille.
Just in case you were wondering, your tool is being used to graph the results of parsing https://github.com/andresriancho/w3af scan log files:
That tool generates nice output which allows me to better understand what w3af is doing internally, and how to improve it.
from plotille.
Wow! 👍 You got another ⭐️! I will definitely look into that project.😄
Since you actually plot datetime
s (as timestamp
deltas), have you tried to insert them directly? Replacing the line 179 by:
error_rate_timestamps = [datetime.datetime.fromtimestamp(ts) for ts in error_rate_timestamps]
and line 198 with:
fig.set_x_limits(min_=datetime.datetime.fromtimestamp(first_timestamp), max_=datetime.datetime.fromtimestamp(last_timestamp))
Depending on the delta (aka spent_epoch
) this will plot the actual time (or day and time).
from plotille.
Applied the changes you recommended to see how the output looked and got an exception:
File "/home/caveman/tools/virtualenvs/w3af/local/lib/python2.7/site-packages/plotille/_figure.py", line 258, in show
self.background, self.color_mode)
File "/home/caveman/tools/virtualenvs/w3af/local/lib/python2.7/site-packages/plotille/_canvas.py", line 68, in __init__
assert isinstance(xmin, (int, float))
AssertionError
The modified code:
def show_extended_urllib_error_rate(scan):
error_rate = []
error_rate_timestamps = []
for line in scan:
match = EXTENDED_URLLIB_ERRORS_RE.search(line)
if match:
error_rate.append(int(match.group(1)))
error_rate_timestamps.append(get_line_epoch(line))
first_timestamp = get_first_timestamp(scan)
last_timestamp = get_last_timestamp(scan)
spent_epoch = last_timestamp - first_timestamp
#error_rate_timestamps = [ts - first_timestamp for ts in error_rate_timestamps]
error_rate_timestamps = [datetime.datetime.fromtimestamp(ts) for ts in error_rate_timestamps]
if not error_rate:
print('No error rate information found')
return
print('Extended URL library error rate')
print(' Error rate exceeded 10%%: %s' % (max(error_rate) > 10,))
print(' Error rate exceeded 20%%: %s' % (max(error_rate) > 10,))
print('')
fig = plotille.Figure()
fig.width = 90
fig.height = 20
#fig.register_label_formatter(float, _num_formatter)
#fig.register_label_formatter(int, _num_formatter)
fig.y_label = 'Error rate'
fig.x_label = 'Time'
fig.color_mode = 'byte'
fig.set_x_limits(min_=datetime.datetime.fromtimestamp(first_timestamp),
max_=datetime.datetime.fromtimestamp(last_timestamp))
fig.set_y_limits(min_=0, max_=max(error_rate) * 1.1)
fig.plot(error_rate_timestamps,
error_rate,
label='Error rate')
print(fig.show())
print('')
print('')
I actually like the way the X axis looks like without the proposed change. I can see seconds since the beginning of the scan, which is easier to understand than a date / hour.
from plotille.
Thank you for the catch! The project is still young and I am happy for every feedback 😁.
from plotille.
Related Issues (20)
- Not getting the graph as required HOT 8
- Four quandrant scatter plot misalignment HOT 7
- Some ideas for optimization. HOT 4
- weird spike at zero HOT 4
- install failed: AttributeError: module 'enum' has no attribute 'IntFlag' HOT 1
- Accept `datetime.date` as X input HOT 6
- Draw vertical or horizontal lines on plots HOT 4
- [feature request] Provide a CLI HOT 3
- Make y-values exakt or approximate values of the data inputs HOT 5
- Histogram breaks when all values are the same HOT 1
- Index out of bounds for hist() on negative values HOT 3
- Two plots side-by-side HOT 4
- has someone ever integrated this on a curses-like interface ? HOT 4
- hex colors not showing up when parsing terminal results HOT 3
- `Figure.axvline(x) coordinates are wrong` HOT 2
- Windows 10 terminal does not display brailles HOT 2
- Log scale for plot() HOT 2
- [Feature request] support arrow HOT 2
- [Feature Request] Treemaps HOT 1
- Feature request: Network graph HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plotille.