我希望使用共享相同比例但缺乏相互 x 值的数据系列来填充 Python 3x 中两行之间的区域(我目前主要在 v3.7 中工作)。
'fill_ Between' 会很方便,但需要两个 y 系列的共同 x 值 matplotlib 文档 matplotlib 演示
数据如下:
x1 = [0.0, 3.2, 10.2, 15.4, 19.9, 24.2, 27.7, 33.9, 50.7, 67.9, 83.7, 102.0, 105.8, 119.4, 129.3, 140.3, 146.0, 150.2, 158.3, 166.7, 168.6, 171.7, 173.5, 175.3, 184.1, 203.7, 220.2, 221.8, 226.8, 231.9]
y1 = [99.95, 99.99, 100.11, 99.59, 98.24, 98.5, 99.21, 99.46, 99.35, 99.18, 98.71, 98.26, 97.92, 97.92, 98.02, 97.63, 97.63, 98.49, 99.17, 98.85, 97.35, 97.43, 98.66, 99.36, 99.14, 99.08, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试填充折线图的背景ggplot
以指示白天/夜间时段。这个答案中的方法效果很好,但我想使用交互式地显示它们ggplotly
,并且由于这个错误而成为一个问题,其中 ggplotly 不喜欢 -Inf 和 Inf 用作 y 限制geom_rect
。有谁知道可以与 ggplotly 一起使用的解决方法吗?
为了便于阅读,我将其他答案中的示例代码粘贴到此处:
library(ggplot2)
dat <- data.frame(x = 1:100, y = cumsum(rnorm(100)))
#Breaks for background rectangles
rects <- data.frame(xstart = seq(0,80,20), xend = seq(20,100,20), col = letters[1:5])
p <- ggplot() +
geom_rect(data = rects, aes(xmin = xstart, xmax = xend, ymin = -Inf, ymax = Inf, fill = col), alpha = 0.4) +
geom_line(data = dat, aes(x,y))
p
Run Code Online (Sandbox Code Playgroud)
但是,如果您这样做:
ggplotly(p) …
Run Code Online (Sandbox Code Playgroud) 我需要在多边形要素中实现多色填充。填充将根据要素属性有条件地格式化。
假设我需要一个具有三色图案的多边形,如下所示:
let fillPalette = ['orange', 'green', 'blue'];
Run Code Online (Sandbox Code Playgroud)
这在传单中怎么可能呢?
简而言之div
,这可以通过以下 CSS 函数轻松实现:
background: repeating-linear-gradient(
-45deg,
orange,
orange 10px,
green 10px,
green 20px,
blue 20px,
blue 30px
);
Run Code Online (Sandbox Code Playgroud)
然而,Leaflet 使用 SVG/Canvas。
我知道以下插件:
不幸的是,第一个似乎不支持多色图案,第二个仅支持图像。
有任何想法吗?
我有数据框(df
),列:( asdfg
字符)和NUMERIC
(数字).
运用
ggplot(df, aes(x = asdfg, y = NUMERIC)) + geom_bar(stat = "identity", fill= "red")
Run Code Online (Sandbox Code Playgroud)
我做了类似的事情:
现在我想得到如下条形图:
我不知道该怎么做.我尝试过使用scale_colour_gradient2
但它不起作用(可能我做错了).
在setContentView()之前
LayoutInflater inflater = (LayoutInflater) getSupportActionBar() .getThemedContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View customActionBarView = inflater.inflate(R.layout.ab, null);
android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayOptions( ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
actionBar.setCustomView(customActionBarView, new android.support.v7.app.ActionBar.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
Run Code Online (Sandbox Code Playgroud)
在ab.xml中
在我的应用程序中
int styles.xml
<!-- Base application theme. -->
<style name="AppBaseTheme" parent="Theme.AppCompat.Light">
</style>
<style name="ATheme" parent="AppBaseTheme">
<item name="android:actionBarStyle">@style/AppTheme.ActionBar.a</item>
<item name="actionBarStyle">@style/AppTheme.ActionBar.a</item>>
<item name="android:icon">@android:color/transparent</item>
</style>
<style name="AppTheme.ActionBar.a" parent="Widget.AppCompat.Light.ActionBar">
<item name="android:height">50dp</item>
<item name="android:background">#d1d1d1</item>
</style>
Run Code Online (Sandbox Code Playgroud)
在我的应用程序中,没有完全填充操作栏
这是一个非常基本的问题.我希望能够为填充和笔划添加定义不同不透明度的形状.如果我添加这个:
Ellipse e = new Ellipse();
e.Width = e.Height = 150;
e.Stroke = Brushes.Aqua;
e.Fill = Brushes.Chartreuse;
e.StrokeThickness = 20;
e.Opacity = .25;
plotCanvas.Children.Add(e);
Run Code Online (Sandbox Code Playgroud)
我只能设置1个不透明度.相反,我希望填充为0.25不透明,并且笔划为1.0不透明.谢谢帕特里克
我希望我的所有svgs都具有相同的纯色.所以我用
svg *{
fill: #ccc;
}
Run Code Online (Sandbox Code Playgroud)
但我希望得到默认填充:悬停.如何禁用填充并恢复默认值?
我试图找到如何遮蔽ggplot中由函数定义的两行之间的区域的可能性.我找到了一些使用geom_area或geom_ribbon的解决方案,但在这两种情况下,您都需要一个数据库,您可以在其中定义ymin和ymax.还有其他可能性吗?在定义ymin和ymax的方式中,也使用与行相同的函数?
这是我的例子:
myplot <- ggplot(data.frame(x=c(0, 100)), aes(x=x)) +
stat_function(fun= function(x)20*sqrt(x), geom="line", colour= "black", size= 1) +
stat_function(fun= function(x)50*sqrt(x), geom="line", colour= "black", size= 1)
myplot
Run Code Online (Sandbox Code Playgroud)
提前谢谢你的帮助.
我有一个称为数量的表:
+----------+----------+
| date | quantity |
+----------+----------+
| 30/11/17 | 90 |
+----------+----------+
| 01/12/17 | |
+----------+----------+
| 02/12/17 | |
+----------+----------+
| 03/12/17 | 1622 |
+----------+----------+
| 04/12/17 | |
+----------+----------+
| 05/12/17 | 9092 |
+----------+----------+
| 06/12/17 | |
+----------+----------+
| 07/12/17 | |
+----------+----------+
| 08/12/17 | 2132 |
+----------+----------+
| 09/12/17 | |
+----------+----------+
| 10/12/17 | 2889 |
+----------+----------+
Run Code Online (Sandbox Code Playgroud)
我想要选择它,以便可以使用先前的非空值来填充空白:
+----------+----------+
| date | quantity |
+----------+----------+
| 30/11/17 | 90 …
Run Code Online (Sandbox Code Playgroud) 我有一个按用户分组的记录.在变量"day"有一些0,我想按顺序(=前一个值+1)替换它.
data <- data.frame(user = c(1,1,1,2,2,2,2,2), day = c(170,0,172,34,35,0,0,38))
data
user day
1 1 170
2 1 0
3 1 172
4 2 34
5 2 35
6 2 0
7 2 0
8 2 38
Run Code Online (Sandbox Code Playgroud)
我想要以下内容:
data_new
user day
1 1 170
2 1 171
3 1 172
4 2 34
5 2 35
6 2 36
7 2 37
8 2 38
Run Code Online (Sandbox Code Playgroud)
我尝试了以下(效率非常低,并不适用于所有情况......):
data = group_by(data, user) %>%
+ mutate(lead_day = lead(day),
+ day_new = case_when(day == 0 …
Run Code Online (Sandbox Code Playgroud)