JetBrains / JetBrains/lets-plot

Geometries with fill have visible gaps

Open
#985 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Kotlin
Stars
1.8k
Forks
60
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.