我正在尝试使用包含来自先前模型的一些数据的构面进行绘图。举一个简单的例子:
t=1:10;
x1=t^2;
x2=sqrt(t);
y1=sin(t);
y2=cos(t);
我如何在2x2网格中绘制此数据,即行是一个因素(级别x
和y
,用不同的颜色绘制)而列是另一个因素(级别1
和2
(以不同的线型绘制)?
注意:t
是所有子图的X轴的公共变量。
答案 0 :(得分:1)
ggplot会更有用。 WiFiEspClient espClient;
PubSubClient client(espClient);
void callback(char* topic, byte* payload, unsigned int length) //print any message received for subscribed topic
{
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < length; i++)
{
Serial.print((char)payload[i]);
}
Serial.println();
}
void WiFiConnect() {
if (WiFi.status() == WL_NO_SHIELD) // check for the presence of the shield
{
Serial.println("WiFi shield not present");
while (true);// don't continue
}
while ( status != WL_CONNECTED) // attempt to connect to WiFi network
{
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass); // Connect to WPA/WPA2 network
}
Serial.println("You're connected to the network"); // you're connected now
client.setServer(server, 1883); //connect to MQTT server
client.setCallback(callback);
}
void reconnect(){
while (!client.connected()) // Loop until we're reconnected
{
Serial.print("Attempting MQTT connection...");
if (loadDataFromSensors()) {
}
if (client.connect("ESP8266Client")) // Attempt to connect, just a name to identify the client
{
Serial.println("connected");
client.subscribe("/Thingworx/PRM9_iot_pub/movespool");
client.publish("/Thingworx/PRM9_iot/SpoolPosition", spoolposString);
client.publish("/Thingworx/PRM9_iot/Teplota", tempString);
client.publish("/Thingworx/PRM9_iot/Vlhkost", humidString);
client.publish("/Thingworx/PRM9_iot/Tlak", presString);
}
else
{
Serial.print("failed, rc=");
Serial.print(client.state());
Serial.println(" try again in 2 seconds");
delay(2000);
}
}
}
是您的数据,df
是整洁的数据,其中的序列在一个列中标识,可以在df_tidy
中映射-在这种情况下为构面。>
ggplot