我正在尝试使用Plotly和R创建一个CPU使用情况图,我想在顶部使用最大使用率(100%,蓝色条),在底部使用另一个,但是当我尝试此代码时
plot_ly( x = cores, y = max, type = 'bar', name = 'Free') %>%
add_trace( y = data, name = 'Used') %>%
layout(
title = "CPU Usage",
font = list(family = 'Comic Sans MS'),
yaxis = list(title = 'Percent'),
xaxis = list(title = '', tickangle = -45),
barmode = 'stack')
})
它给了我相反的效果,在底部排列较大的条,在顶部排列橙色的条。我要反转它。
我搜索了一些references,但没有发现任何东西...
答案 0 :(得分:1)
我们不知道您的数据,但是:
Private Sub btn_Import_Click()
On Error GoTo ErrHandle
Dim StrFileName As String
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
' ITERATE THROUGH MULTIPLE FILE PICKER
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd.InitialFileName = "c:\sample\*.xml"
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
' TRANSFORM XML FILE
StrFileName = CombineNodesXML(vrtSelectedItem)
' IMPORT TRANSFORMED XML (APPENDING TO EXISTING)
Application.ImportXML StrFileName, acAppendData
Next vrtSelectedItem
End If
End With
ExitHandle:
Set fd = Nothing
Exit Sub
ErrHandle:
Msgbox Err.Number & " - " & Err.Description, "RUNTIME ERROR", vbCritical
Resume ExitHandle
End Sub
Public Function CombineNodesXML(xmlfile As Variant) As String
On Error GoTo ErrHandle
Dim xmldoc As New MSXML2.DOMDocument, xslDoc As New MSXML2.DOMDocument, newDoc As New MSXML2.DOMDocument
Dim outputfile As String
outputfile = Replace(xmlfile, ".xml", "_transformed.xml")
' LOAD XML AND XSL FILES
xmlDoc.async = False
xmlDoc.Load xmlfile
xslDoc.async = False
xslDoc.Load "C:\Path\To\XSLT_Script.xml" ' REPLACE WITH ABOVE XSLT PATH
' TRANSFORM AND SAVE XML
xmldoc.transformNodeToObject xslDoc, newDoc
newDoc.Save outputfile
' RETURN OUTPUT PATH
CombineNodesXML = outputfile
ExitHandle:
' RELEASE OBJECTS
Set xmlDoc = Nothing: Set xslDoc = Nothing: Set newDoc = Nothing
Exit Function
ErrHandle:
Msgbox Err.Number & " - " & Err.Description, "RUNTIME ERROR", vbCritical
Resume ExitHandle
End Sub