JetBrains / JetBrains/lets-plot

Geometries with fill have visible gaps

Aperta
#985 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Kotlin
Stelle
1.8k
Fork
60
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Some of the plots don't look very appealing:

```python
import numpy as np
from lets_plot import *
LetsPlot.setup_html()

np.random.seed(43)
data = {
'x': np.append(np.random.normal(0,1,1000), np.random.normal(3,1,500)),
'y': np.append(np.random.normal(0,1,1000), np.random.normal(3,1,500))
}
ggplot(data, aes('x', 'y')) + geom_density2df(aes(fill = '..level..'))
```
![image](https://github.com/JetBrains/lets-plot/assets/14200189/fe928635-ee5a-4285-b318-3c1463ab8543)

```python
import pandas as pd
from lets_plot import *
LetsPlot.setup_html()

df = pd.read_csv("https://raw.githubusercontent.com/JetBrains/lets-plot-docs/master/data/mpg.csv")

n = 12
quantiles=[i/n for i in range(0, n)]

ggplot(df, aes('hwy', group='drv')) + \
geom_density(aes(fill='..quantile..'), quantiles=quantiles, alpha=.97, show_legend=False) + \
ggsize(800, 300)
```
![image](https://github.com/JetBrains/lets-plot/assets/14200189/81ed6b45-b2fe-4043-8568-d254ef5b686d)

```python
import math
from lets_plot import *
LetsPlot.setup_html()

X_max = 50
Y_max = 50
def z_fun(x, y):
z = math.sin(x * 3 * math.pi / X_max)
z += math.sin(y * 3 * math.pi / Y_max)
z += x * 3 / X_max
z += y * 5 / Y_max
return z

x = []
y = []
z = []

for row in range(0, Y_max - 1):
for col in range(0, X_max - 1):
x.append(col)
y.append(row)
z.append(z_fun(col, row))

dat = dict(x=x, y=y, z=z)

ggplot(dat) + geom_contourf(aes('x', 'y', z='z', fill='..level..'), bins=20)
```
![image](https://github.com/JetBrains/lets-plot/assets/14200189/238cc1c5-3189-4212-ba54-fba29dcb63d9)

We can try to fix this by using an integer grid. If the coordinate is next to an occupied cell - use the coordinates of the cell, otherwise round the coordinate and take the place in the grid.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Reproduce the visible gaps with the provided geom_density2df, geom_density, and geom_contourf examples. Start by tracing how filled geometry coordinates are generated and rasterized, then evaluate the proposed integer-grid handling for occupied neighboring cells. Done means the supplied filled plots render without visible gaps.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
kotlin, python
Ambito
data-visualization
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.