Comments (8)
Hello, Nothing that I could see so far. Could you share some date from sensor.historic_data_temperature, That would facilitate the testing and we will have the same values. Thanks :)
from circuitpython_uplot.
I do not have that values. But basically, the first graph in temperature and the other humidity. The list of values on the graph are initial very few values with similar values as seen in text / numeric values. The rest of values are all '0'.
Why would the graph not show the line on the '0' values, when I define a rangey value?
from circuitpython_uplot.
I need to set rangy for first graph to [0 - 50] that is temperature and [0 - 100] that is humidity. How should I do it, can you please suggest and I will do it?
This is the graph with real values, but automatic Y range... on the last points / 30 minutes, I did open the door and so the temperature decreased and humidity increased, that is correct:
from circuitpython_uplot.
Hello, yes I was suspecting that you were trying to do something like that. What you could do is to plot only the range that is needed, and incremented in a loop, if that is what you need
import displayio
from adafruit_display_text import label
import terminalio
from circuitpython_uplot.ucartesian import ucartesian
from random import choice
import time
import board
from circuitpython_uplot.uplot import Uplot
# Setting up the display
display = board.DISPLAY
plot = Uplot(0, 0, display.width, display.height)
g = displayio.Group()
# Set a white background
# Create the display object - the third color is red (0xff0000)
DISPLAY_WIDTH = 200
DISPLAY_HEIGHT = 200
BLACK = 0x000000
WHITE = 0xFFFFFF
FOREGROUND_COLOR = BLACK
BACKGROUND_COLOR = WHITE
background_bitmap = displayio.Bitmap(DISPLAY_WIDTH, DISPLAY_HEIGHT, 1)
# Map colors in a palette
palette = displayio.Palette(1)
palette[0] = BACKGROUND_COLOR
# Create a Tilegrid with the background and put in the displayio group
t = displayio.TileGrid(background_bitmap, pixel_shader=palette)
g.append(t)
text_temperature = label.Label(terminalio.FONT, color=FOREGROUND_COLOR, scale=3)
text_temperature.anchor_point = 0.0, 0.0
text_temperature.anchored_position = 25, 0
g.append(text_temperature)
text_humidity = label.Label(terminalio.FONT, color=FOREGROUND_COLOR, scale=3)
text_humidity.anchor_point = 0.0, 0.0
text_humidity.anchored_position = 130, 0
g.append(text_humidity)
plot_1 = Uplot(
0,
50,
200,
60,
padding=1,
show_box=True,
box_color=BLACK,
background_color=WHITE)
plot_2 = Uplot(
0,
180,
200,
60,
padding=1,
show_box=True,
box_color=BLACK,
background_color=WHITE)
temperatures = [26, 25, 24, 23, 28]
humidity = [66, 67, 71, 79]
x = list(range(0, 144, 1))
temp_y = [choice(temperatures) for _ in x]
humidity_y = [choice(humidity) for _ in x]
g.append(plot_1)
g.append(plot_2)
display.show(g)
display.refresh()
for i, element in enumerate(x):
ucartesian(plot_1, x[0:i], temp_y[0:i], rangex=[0, 143], rangey=[0, 40], fill=False, line_color=BLACK)
ucartesian(plot_2, x[0:i], humidity_y[0:i], rangex=[0, 143], rangey=[0, 100], fill=False, line_color=BLACK)
text_temperature.text = f'{temp_y[i]}'
text_humidity.text = f'{int(round(humidity_y[i], 0))}%'
time.sleep(0.1)
As you can see, even the list is made of 144 values, I am only plotting some of them depending of the i.
What I would do is this
data_end = find the last non-zero value in sensor.historic_data_temperature (EDITED)
# and then
ucartesian(plot_1, x[0:data_end], temp_y[0:data_end], rangex=[0, 143], rangey=[0, 40], fill=False, line_color=BLACK)
ucartesian(plot_2, x[0:data_end], humidity_y[0:data_end], rangex=[0, 143], rangey=[0, 100], fill=False, line_color=BLACK)
from circuitpython_uplot.
This is the graph with real values, but automatic Y range... on the last points / 30 minutes, I did open the door and so the temperature decreased and humidity increased, that is correct:
Depending on the part of the planet that you live, this could be possible, also heating, A/C. for me at the moment will be if I open the door, will be temperature decrease, humidity decrease :).
from circuitpython_uplot.
BTW, this is hack, Library was not intended to dynamic data, maybe you could use the sparkline shapes library, I have just an example here https://github.com/jposada202020/CircuitPython_uplot/blob/main/examples/uplot_sparkline.py or the original one in the library https://github.com/adafruit/Adafruit_CircuitPython_Display_Shapes/blob/main/adafruit_display_shapes/sparkline.py.
from circuitpython_uplot.
@casainho made some changes, take a look at the example here https://github.com/jposada202020/CircuitPython_uplot/blob/main/examples/uplot_ucartesian_loggin_data.py
result: https://github.com/jposada202020/CircuitPython_uplot/blob/main/docs/uplot_cartesian.gif
Changes are in 0.8.2. Thanks
from circuitpython_uplot.
It works!! Now rangey works as expected. Thank you.
from circuitpython_uplot.
Related Issues (15)
- ISSUE: box color needs to be custom HOT 3
- Need better scale description HOT 3
- ubar 4th refresh index out of range HOT 6
- Setting the max_value to larger than screen size blows up with height must be above 1. HOT 3
- Setting uplot padding to 0 doesnt behave as expected HOT 2
- Bar3d Returns None HOT 1
- Bar Plot Scale space between bars not working HOT 1
- Add a tickheight for x and tickheight for y HOT 3
- ISSUE: first pixel is never shown HOT 1
- ISSUE: first pixel is never shown HOT 2
- Please add number of tickx and ticky HOT 11
- Please implement Thickness HOT 4
- Release zip file without the compiled python files HOT 4
- IDEA: fill with a mesh on white and black EInk displays HOT 7
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 circuitpython_uplot.