好的,所以我有以下代码:
var element = document.getElementById(scope.changeid);
function getData(division,redraw) {
var employeeData = [];
if (!division) {
$http.get(api.getUrl('competenceUserAverageByMyDivisions', null)).success(function (response) {
processData(response,redraw);
});
}
else {
$http.get(api.getUrl('competenceUserAverageByDivision', division)).success(function (response) {
processData(response,redraw);
})
}
}
function processData(data,redraw) {
var y = [],
x1 = [],
x2 = [];
data.forEach(function (item) {
y.push(item.user.profile.firstname);
x1.push(item.current_level);
x2.push(item.expected);
});
var charData = [{
x: x1,
y: y,
type: 'bar',
orientation: 'h',
name: 'Nuværende'
}, {
x: x2,
y: y,
type: 'bar',
orientation: 'h',
name: 'Forventet'
}],
layout …Run Code Online (Sandbox Code Playgroud) 有没有办法防止Plotly在向折线图添加标记时更改x轴上的填充.请参阅下面的两个片段.唯一的区别是第24行'lines'改为'lines+markers'.
没有标记的第一个片段:
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<div id="myDiv">
</div>
<script>
var layout = {
xaxis: {
showticklabels: true,
tickmode: 'auto',
nticks: 15,
tickangle: 45,
rangemode: 'tozero',
},
};
var trace1 = {
x: ['Week 1', 'Week 2', 'Week 3', 'Week 4', 'Week 5', 'Week 6', 'Week 7', 'Week 8'],
y: [10, 15, 13, 17, 10, 15, 13, 17],
type: 'scatter',
mode: 'lines',
};
var data = [trace1];
Plotly.newPlot('myDiv', data, layout);
</script>
</body>Run Code Online (Sandbox Code Playgroud)
带标记的第二个片段:
<head>
<script …Run Code Online (Sandbox Code Playgroud)我有一个功能r(x),我想围绕x轴旋转,以获得我想要使用(着色)添加到现有绘图的旋转实体.plot_lyadd_surfacex
这是一个例子:
library(dplyr)
library(plotly)
# radius depends on x
r <- function(x) x^2
# interval of interest
int <- c(1, 3)
# number of points along the x-axis
nx <- 20
# number of points along the rotation
ntheta <- 36
# set x points and get corresponding radii
coords <- data_frame(x = seq(int[1], int[2], length.out = nx), r = r(x))
# for each x: rotate r to get y and …Run Code Online (Sandbox Code Playgroud) 我正在尝试在每个循环中添加ad_trace广告,但我只得到一个图表,其中彼此相乘.
mean <- -0.0007200342
sd <- 0.3403711
N=10
T=1
Delta = T/N
W = c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd)))
t <- seq(0,T, length=N+1)
p<-plot_ly(y=W, x=t)
for(i in 1:5){
W <- c(0,cumsum( sqrt(Delta) * rnorm(N, mean=mean, sd=sd)))
p<-add_trace(p, y=W)
}
print(p)
Run Code Online (Sandbox Code Playgroud)
我想填写直到PlotlyJS中的特定Y值.这是我从PlotlyJS文档得到的:小提琴
{
"x": [
"2016-01-31T00:03:57.000Z",
"2016-02-12T04:35:26.000Z"
],
"y": [
100,
100
],
"fill": "tonexty",
"fillcolor": "#8adcb3"
}
Run Code Online (Sandbox Code Playgroud)
在文档中,似乎有两种选择:
tonexty - 填写如下.问题是'tonexty'有点限制 - 用例是'填充直到',所以阴影只能在110以上.示例:tozeroy - 填写至零:此外,您是否需要引入新的跟踪以创建填充?
这意味着如果我有一个如下图表(只有一条迹线但是一条阈值线作为一个形状):我需要引入另一条线来创建一个填充.也许我在文档中遗漏了一些东西,或者这完全是错误的方法.

那么,如何填充PlotlyJS中特定Y值以上的迹线区域?
我希望能够在以下代码中为图例添加标题.但是,看一下这些文档,我认为没有办法解决这个问题.
import plotly.plotly as py
import plotly.graph_objs as go
trace0 = go.Scatter(
x=[1, 2, 3, 4, 5],
y=[1, 2, 3, 4, 5],
)
trace1 = go.Scatter(
x=[1, 2, 3, 4, 5],
y=[5, 4, 3, 2, 1],
)
data = [trace0, trace1]
fig = go.Figure(data=data)
py.iplot(fig, filename='default-legend')
Run Code Online (Sandbox Code Playgroud) 我正在使用ggplotly来显示交互式时间序列图.x轴采用日期格式,但悬浮工具提示正在将日期格式转换为数字(附加截图).关于如何在工具提示中将日期显示为正确日期的任何想法?
下面是一小段代码:
output$ggplot <- renderPlotly({
plotbycity<-df_postgres %>% group_by(city, date, bedroooms) %>%
filter(city %in% input$checkGroup & bedroooms==input$radio) %>%
summarise(count=n(),rent=median(rent)) %>%
ungroup()
plotbycity$date<-as.Date(plotbycity$date)
# Error handling
plotbycity<-plotbycity[!is.na(plotbycity$city),]
if (is.null(plotbycity)) return(NULL)
#plotbycity<-ungroup(plotbycity)
#dat <- dat[c("rent", "bedroooms", "date", "City")]
#dat <- melt(dat,id.vars=c("date", "City", "bedroooms"),na.rm=TRUE) #
# draw the line plot using ggplot
gg <-ggplot(plotbycity, aes(x = date, y = rent, group = city, color = city,
text = paste('obs: ', count))) +
geom_line() +
ggtitle("Monthly Rents")
# #theme_hc(bgcolor = "darkunica") +
# #scale_fill_hc("darkunica")
p …Run Code Online (Sandbox Code Playgroud) 是否可以在Jupyter笔记本中使用破折号应用程序,而不是在浏览器中提供和查看?
我的目的是,使得鼠标悬停在一个图表生成用于另一曲线图所需要的输入Jupter笔记本内链接的曲线图.
我正在尝试在Jupyter笔记本中创建一个Sankey图表,我的代码基于此处显示的第一个示例.
我最终得到了这个,我可以运行而不会出现任何错误:
import numpy as npy
import pandas as pd
import plotly as ply
ply.offline.init_notebook_mode(connected=True)
df = pd.read_csv('C:\\Users\\a245401\\Desktop\\Test.csv',sep=';')
print(df.head())
print(ply.__version__)
data_trace = dict(
type='sankey',
domain = dict(
x = [0,1],
y = [0,1]
),
orientation = "h",
valueformat = ".0f",
node = dict(
pad = 10,
thickness = 30,
line = dict(
color = "black",
width = 0.5
),
label = df['Node, Label'].dropna(axis=0, how='any'),
color = df['Color']
),
link = dict(
source = df['Source'].dropna(axis=0, how='any'),
target = df['Target'].dropna(axis=0, …Run Code Online (Sandbox Code Playgroud) plotly ×10
javascript ×4
python ×3
r ×3
r-plotly ×2
angularjs ×1
d3.js ×1
ggplot2 ×1
jupyter ×1
jupyter-lab ×1
plot ×1
plotly-dash ×1
shiny ×1
surface ×1