Enabling 3D plots?
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 28/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- matplotlib, python
- Lĩnh vực
- data-visualization
Hướng nghiên cứu
Bắt đầu với plotnine/ggplot.py, đặc biệt là _build, _create_figure và _create_subplots, sau đó kiểm tra plotnine/facets/layout.py và geom_point.draw_groups(). So sánh các điểm mở rộng được đề xuất với cách xử lý faceting và tọa độ hiện có. Công việc được xem là hoàn tất khi có một triển khai đã được thống nhất hỗ trợ biểu đồ 3D và faceting, hoặc có một hướng mở rộng rõ ràng nếu hỗ trợ 3D gốc nằm ngoài phạm vi.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Could 3D plots be supported by plotnine, or if not, could the internals be slightly adjusted to enable easy extension to 3D plots? Currently with a simple hack it is possible to get a simple 3d plotnine plot:
from plotnine import scale_color_manual, scale_shape_manual, theme_minimal
from plotnine.data import mtcars
mtcars['transmission'] = mtcars['am'].replace({0: 'automatic', 1: 'manual'})
(
ggplot_3d(mtcars)
+ aes(x='hp', y='disp', z='mpg', shape='transmission', color='transmission')
+ geom_point_3d()
+ theme_minimal()
+ scale_shape_manual(values={'automatic': 'o', 'manual': '*'})
+ scale_color_manual(values={'automatic': 'red', 'manual': 'blue'})
)

The hack is:
from plotnine import ggplot, geom_point
from plotnine.utils import to_rgba, SIZE_FACTOR
class ggplot_3d(ggplot):
def _create_figure(self):
figure = plt.figure()
axs = [plt.axes(projection='3d')]
figure._themeable = {}
self.figure = figure
self.axs = axs
return figure, axs
def _draw_labels(self):
ax = self.axs[0]
ax.set_xlabel(self.layout.xlabel(self.labels))
ax.set_ylabel(self.layout.ylabel(self.labels))
ax.set_zlabel(self.labels['z'])
class geom_point_3d(geom_point):
REQUIRED_AES = {'x', 'y', 'z'}
@staticmethod
def draw_unit(data, panel_params, coord, ax, **params):
size = ((data['size']+data['stroke'])**2)*np.pi
stroke = data['stroke'] * SIZE_FACTOR
color = to_rgba(data['color'], data['alpha'])
if all(c is None for c in data['fill']):
fill = color
else:
fill = to_rgba(data['fill'], data['alpha'])
ax.scatter3D(
data['x'],
data['y'],
data['z'],
s=size,
facecolor=fill,
edgecolor=color,
marker=data.loc[0, 'shape'],
)
@staticmethod
def draw_group(data, panel_params, coord, ax, **params):
data = coord.transform(data, panel_params)
units = 'shape'
for _, udata in data.groupby(units, dropna=False):
udata.reset_index(inplace=True, drop=True)
geom_point_3d.draw_unit(udata, panel_params, coord, ax, **params)
However, because it is bypassing self.facet.make_axes() call in _create_figure() it does not support faceting.
While I would prefer plotnine to just support 3D plots, I fully respect if this is not aligned with the vision of the project; in that case the following places could be reworked to simplify extending:
- to allow extending
geom_pointeasier, thegeom_point.draw_groups()method could be a classmethod rather than a static method, and instead of using hard-codedgeom_pointit would usecls; presumably this would be also need for other geoms which can have 3d equivalents (line, area, etc). - to allow to add zlabel special handling in addition to
xlabelandylabela new common methodLayout.label(self, labels, axis)could replaceLayout.xlabel(self, labels)andLayout.ylabel(self, labels)OR the hard-coded use ofself.layout = Layout()inggplot._buildcould be replaced with either a new methodggplot._init_layout()or a new class attributelayout_class = Layoutcould be added (and then the call would be replaced withself.layout = self.layout_class()); - to allow for faceting support, the
fig.add_subplot(gs[i - 1])call in_create_subplotsshould allow to passprojection='3d'keyword argument; this could be conditional on layout having a projection attribute.
Of course there some more changes for full integration (e.g. fliping of coordinates would need to know around which axis), but I believe that very little changes would be needed to gain quite a lot in terms of usability.
- Ngôn ngữ chính
- Python
- Star
- 4.8k
- Fork
- 260
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của has2k1/plotnine
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Enhancement
Độ khó 3/5 Nửa ngày Mức phù hợp với người mới 55/100
has2k1/plotnine#1141 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
has2k1/plotnine#1081 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Discussion
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
has2k1/plotnine#1047 · 15 bình luận · 3 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Documentation Plot Composition Question
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
has2k1/plotnine#1036 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của has2k1/plotnine
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Treat corrupt-shape state files as missing in `load_state`Có thể đã có người làm @Qrytics đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
OvertureMaps/overturemaps-py#175 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
awslabs/visual-asset-management-system#1278 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws-samples/sample-per-model-bedrock#835 ·
Maintainer thường phản hồi trong vòng 1 ngày